空心三角形指示箭頭
阿新 • • 發佈:2017-09-26
log 邊框 block for charset back borde 技術分享 nbsp
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>空心三角形指示箭頭</title> <style> .box { position: relative; width: 300px; height: 100px; border: 6px solid #555; border-radius: 20px; margin: 100px auto; background-color: #8a98ff; } /*第一個三角形*/ .box::before{ /*這裏的偽元素用單冒號和雙冒號都一樣*/ content: ‘‘; display: block; position: absolute; top: -26px; left: 80px; border-left: 20px solid transparent ; border-right: 20px solid transparent; border-bottom: 20px solid #555; } /*第二個三角形*/ .box::after{ content: ‘‘; display: block; position: absolute; top: -17.6px; /*向下偏移量是矩形邊框寬度的1.4(根號2)倍,即8.4,top值為-26-(-8.4)*/ left: 80px; border-left: 20px solid transparent; border-right: 20px solid transparent; border-bottom: 20px solid #8a98ff; } </style> </head> <body> <div class="box"></div> </body> </html>
空心三角形指示箭頭