Применить CSS blend-mode только к границам
Я работал над небольшим веб-сайтом, как упражнение для интеграции. Но так как я не обладаю расширенными знаниями CSS, я не знаю, возможно ли это в конце концов:
У меня на сайте есть форма с текстовыми полями, окруженными рамкой, к которой я применил режим наложения в Photoshop. Любопытно узнать, существует ли он в CSS, я быстро опробовал его, но застрял, пытаясь применить режим mix-blend-mode только на границе.
Есть ли способ сделать это или селектор, который позволил бы мне достичь только границы и ничего больше?
Спасибо за ваши ответы!
2 ответа
Изменение padding
из .border-gradient
изменит ширину "границы".
.border-gradient {
padding: 4px;
background: #1e5799;
background: -moz-linear-gradient(-45deg, #1e5799 0%, #7db9e8 100%);
background: -webkit-linear-gradient(-45deg, #1e5799 0%,#7db9e8 100%);
background: linear-gradient(135deg, #1e5799 0%,#7db9e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=1 );
}
.border-gradient > .margin-fix {
background-color: white;
padding: 1px;
margin: -1px;
}
p {
padding: 0 1rem;
}
<div class="border-gradient">
<div class="margin-fix">
<p>[32] But I must explain to you how all this mistaken idea of denouncing of a pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?
<p>[33] On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammeled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.
</div>
</div>
Обратите внимание, что создание кросс-браузерных градиентов фона еще не тривиально. Я рекомендую использовать онлайн-инструмент, такой как этот - не одобрен или рекомендован, найдите другой, если он вам не нравится:).
Вот оно с blend-mode
:
.blended {
padding: 20px;
background: red url('http://lorempixel.com/g/800/600/fashion') no-repeat 50% 50% /cover;
background-blend-mode: multiply;
}
.blended > .margin-fix {
background-color: white;
padding: 1px;
margin: -1px;
}
p {
padding: 0 1rem;
}
<div class="blended">
<div class="margin-fix">
<p>[32] But I must explain to you how all this mistaken idea of denouncing of a pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?
<p>[33] On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammeled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.
</div>
</div>
Ты можешь использовать border-image
свойство, но будьте осторожны с современной поддержкой браузера, особенно IE.
Смотрите поддержку браузера здесь
Вот подход, который выглядит как хорошая многоцветная граница
Фрагмент ниже
div {
position: relative;
background: linear-gradient(to right, #bcbcbc 25%, #ffcd02 25%, #ffcd02 50%, #e84f47 50%, #e84f47 75%, #65c1ac 75%);
padding: 5px;
display: inline-block;
}
form {
width: 100%;
height: 100%;
display: inline-block;
background: white;
}
<div>
<form>
<input>
<input>
</form>
</div>