仅将CSS混合模式应用于边框

时间:2017-04-08 17:07:37

标签: html css css3 mix-blend-mode blend-mode

我一直在小型网站上工作,就像整合练习一样。但由于我没有CSS的扩展知识,我不知道最终是否可能:

我在网站上有一个表格,文本框被边框包围,我在Photoshop中应用了混合模式。很想知道它是否存在于CSS中,我很快就尝试了,但是只是试图在边界上应用混合混合模式而陷入困境。

无论如何要做到这一点,还是选择器让我只能到达边界而没有别的?

感谢您的回答!

2 个答案:

答案 0 :(得分:1)

更改padding的{​​{1}}会更改" border" 的宽度。



.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;
}




请注意,创建跨浏览器背景渐变并非易事。我建议使用在线工具,例如this one - 未经认可或推荐,如果您不喜欢,请找另一个工具:)。

这是<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>

&#13;
&#13;
blend-mode
&#13;
.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;
}
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您可以使用border-image属性,但要谨慎使用现代浏览器支持,特别是IE。

请参阅浏览器支持here

这是一种看起来很漂亮的多色边框的方法

  • 将表单标记包装在容器中,使表单标记占用所有空间。
  • 在父容器中,应用背景颜色和一些周围的填充。

    下面的代码段

    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>