「 CSS 」通过伪元素来得到一些常见的icon Posted on 2017-03-18 | Comments: | Views: 通过伪元素:before和:after来得到一些常用的icon 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465// caret.icon_caret { display: block; margin: 5px 0 0 5px; width: 0; height: 0; line-height: 0; font-size: 0; border-width: 5px; border-style: solid; border-color: #9d9d9d transparent transparent transparent;}// >.icon_gter{ width: .16rem; height: .16rem; margin: 0 12px; display: block; position: relative; margin-top: 0; &:after{ content: ""; width: .08rem; height: .08rem; border-width: 1px; border-style: solid; border-color: transparent transparent rgba(0,0,0,0.3) rgba(0,0,0,0.3); -webkit-transform: rotate(-135deg); transform: rotate(-135deg); position: absolute; left: .05rem; top: .04rem; }}// <.icon_lser{ width: .16rem; height: .16rem; margin: 0 12px; display: block; position: relative; margin-top: 0; &:after{ content: ""; width: .08rem; height: .08rem; border-width: 1px; border-style: solid; border-color: transparent transparent rgba(0,0,0,0.3) rgba(0,0,0,0.3); -webkit-transform: rotate(-45deg); transform: rotate(-45deg); position: absolute; left: .05rem; top: .04rem; }}.triangle{ width:0; height:0; border-width:20px; border-style:solid; border-color:transparent transparent red transparent;} 注意每个border-color对应一个三角形 关注Eva的意如小馆,更方便的与我交流