作者:起来吧52 | 来源:互联网 | 2023-05-28 18:46
我如何制作这种类型的五角形,-webkit-clip-path
因为它不适用于Firefox,IE9等大多数浏览器.
我的代码:http://codepen.io/anon/pen/MYbKrQ
div {
width: 150px;
height: 150px;
background: #1e90ff;
-webkit-clip-path: polygon(0% 0%, 75% 0%, 100% 50%, 75% 100%, 0% 100%);
clip-path: polygon(0% 0%, 75% 0%, 100% 50%, 75% 100%, 0% 100%);
}
/* Center the demo */
html, body {
height: 100%;
}
body {
display: flex;
justify-content: center;
align-items: center;
}
1> Weafs.py..:
你可以直接使用svg
.
2> Gildas.Tambo..:
UPDATE
您可以使用currentcolor来破解背景图像.
*{
box-sizing: border-box;
padding: 0;
margin: 0
}
:root{
background: red
}
div{
margin: 20px auto;
background: url(http://i.imgur.com/mI2OFTB.jpg);
background-size: cover;
width: 300px;
height: 200px;
position:relative;
color: red
}
div:before,div:after{
content: "";
position: absolute;
color: currentcolor;
right: 0;
border-left: 100px solid transparent
}
div:before{
border-bottom: 100px solid currentcolor;
bottom: 0
}
div:after{
border-top: 100px solid currentcolor
}