【发布时间】:2014-11-02 13:35:17
【问题描述】:
我正在尝试在图像前面创建一个空心 css 箭头。
我明白了……但感觉很脏。有没有更好的方法来做到这一点? 跨浏览器兼容性(IE8+)会很棒。
SCSS
.arrowwrap {
width:100%;
padding:0;
position:relative;
overflow:hidden;
margin:-$arrow_height 0 0 0;
&:after {
content:'';
position:absolute;
height:$arrow_height;
width:50%;
margin:-$arrow_height 0 0 -$arrow_width;
left:0;
z-index:99999;
background:$box_color;
}
&:before {
content:'';
position:absolute;
height:$arrow_height;
width:100%;
left:50%;
margin:0 0 0 $arrow_width;
z-index:99999;
background:$box_color;
}
.arrowone {
width: 0;
height: 0;
border-style: solid;
border-width: $arrow_height $arrow_width 0 $arrow_width;
/* border-color: transparent transparent #333 transparent; */
border-color:transparent $box_color $box_color $box_color;
margin:auto;
}
}
【问题讨论】:
-
看不懂“感觉很脏”
-
@Alek 他的意思是它需要一个非语义箭头元素,并且除此之外还依赖
before和after。对于他认为应该更容易做的事情,这是很多标记 -
你可以用 svg 和 png 作为后备,你尝试过吗?
标签: html css sass css-shapes