如何在这个8点星外面添加红色边框?或者有没有人知道的简单的svg解决方案?
IS: 需要:
JS小提琴
HTML
CSS
#star8 { border: 3px solid red; background: blue; width: 80px; height: 80px; position: relative; -webkit-transform: rotate(20deg); -moz-transform: rotate(20deg); -ms-transform: rotate(20deg); -o-transform: rotate(20eg); } #star8:before { content: ""; position: absolute; top: 0; left: 0; height: 80px; width: 80px; background: blue; -webkit-transform: rotate(135deg); -moz-transform: rotate(135deg); -ms-transform: rotate(135deg); -o-transform: rotate(135deg); }
G-Cyr.. 6
你可以使用mix-blend-mode,最后使用另一个伪:DEMO
#star8:after { content: ""; position: absolute; top: 0; left: 0; height: 80px; width: 80px; transform: rotate(135deg); box-shadow: 0 0 0 3px red;::* a border works too */ mix-blend-mode:overlay; }
#star8 {
margin: 2em;
border: 3px solid red;
background: blue;
width: 80px;
height: 80px;
position: relative;
transform: rotate(20deg);
}
#star8:before {
content: "";
position: absolute;
top: 0;
left: 0;
height: 80px;
width: 80px;
background: blue;
transform: rotate(135deg);
}
#star8:after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 80px;
width: 80px;
transform: rotate(135deg);
box-shadow: 0 0 0 3px red;
mix-blend-mode:overlay;
}
没有mix-blend-mode
,但z-index
并:after
#star8 {
margin: 2em;
border: 3px solid red;
background: blue;
width: 80px;
height: 80px;
position: relative;
transform: rotate(20deg);
}
#star8:before {
content: "";
position: absolute;
z-index:-1;
top: 0;
left: 0;
height: 80px;
width: 80px;
background: blue;
transform: rotate(135deg);
box-shadow: 0 0 0 3px red;
}
#star8:after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 80px;
width: 80px;
background: blue;
transform: rotate(0deg);
}
你也可以只绘制部分bg (via linear-gradient
)来隐藏不需要的边框部分,并在里面添加一些文字:http://codepen.io/gc-nomade/pen/KWNmqw
你可以使用mix-blend-mode,最后使用另一个伪:DEMO
#star8:after { content: ""; position: absolute; top: 0; left: 0; height: 80px; width: 80px; transform: rotate(135deg); box-shadow: 0 0 0 3px red;::* a border works too */ mix-blend-mode:overlay; }
#star8 {
margin: 2em;
border: 3px solid red;
background: blue;
width: 80px;
height: 80px;
position: relative;
transform: rotate(20deg);
}
#star8:before {
content: "";
position: absolute;
top: 0;
left: 0;
height: 80px;
width: 80px;
background: blue;
transform: rotate(135deg);
}
#star8:after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 80px;
width: 80px;
transform: rotate(135deg);
box-shadow: 0 0 0 3px red;
mix-blend-mode:overlay;
}
这可以使用单个svg路径创建.添加轮廓可以通过向路径添加笔划属性来完成