css有一系列的伪元素,如:before,:after,:first-line,:first-letter等。
1、CSS部分
.triangle{ width: 200px; height: 100px; border-radius: 5px; border: 2px solid #000; position: relative; } .triangle:after{ content: ""; position: absolute; left: 200px; top:12px; width: 0; height: 0; border-top: 10px solid transparent; border-left: 10px solid #fff; border-right: 10px solid transparent; border-bottom: 10px solid transparent; } .triangle:before{ content: ""; position: absolute; left: 200px; top:10px; width: 0; height: 0; border-top: 12px solid transparent; border-left: 12px solid #000; border-right: 12px solid transparent; border-bottom: 12px solid transparent; }
2、html部分 一个div就可以搞定
3、效果图

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/229618.html原文链接:https://javaforall.net
