边框图像与不透明度

时间:2017-07-13 15:40:29

标签: css css3 opacity border-image

我有这个:

.striped-border {
    border: 8px solid transparent;
    border-image: url(../img/stripes.png) 9 round;
}

Content with a border-image

我想要的是什么:

enter image description here

是否可以将不透明度应用于仅限边框图像而不是内容?

2 个答案:

答案 0 :(得分:6)

您可以使用pseudo-element创建border-image边框,然后设置opacity



div {
  position: relative;
  margin: 50px;
  font-size: 25px;
  padding: 10px 25px;
  display: inline-block;
}
div:after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: 5px solid transparent;
  border-image: url('http://www.circlek.org/Libraries/2013_branding_design_elements/graphic_CKI_horizontal_stripesblue_RGB.sflb.ashx') 22 22 repeat;
  transform: translate(-5px, -5px);
  opacity: 0.4;
}

<div>Element</div>
<div>Element <br> lorem</div>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

类似的东西:

.striped-border:after{
    content:"";
    position:absolute;
    top:0; bottom:0; left:0; right:0;
    border:8px solid rgba(256,256,256, 0.5);
}