我一直在一个小型网站上工作,就像一个集成练习。但是由于我对CSS没有扩展知识,所以我不知道最终是否可能:
我在网站上有一个表单,文本框被边框包围,我在 Photoshop 中应用了混合模式。很想知道它是否存在于 CSS 中,我很快尝试了一下,但在尝试仅在边框上应用 mix-blend-mode 时卡住了。
有没有办法做到这一点,或者有一个选择器可以让我只到达边界而没有别的?
感谢您的回答!
我一直在一个小型网站上工作,就像一个集成练习。但是由于我对CSS没有扩展知识,所以我不知道最终是否可能:
我在网站上有一个表单,文本框被边框包围,我在 Photoshop 中应用了混合模式。很想知道它是否存在于 CSS 中,我很快尝试了一下,但在尝试仅在边框上应用 mix-blend-mode 时卡住了。
有没有办法做到这一点,或者有一个选择器可以让我只到达边界而没有别的?
感谢您的回答!
更改padding
of.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>