重慶分公司,新征程啟航
為企業(yè)提供網(wǎng)站建設、域名注冊、服務器等服務
為企業(yè)提供網(wǎng)站建設、域名注冊、服務器等服務
本篇文章展示了css3實現(xiàn)三角形的具體操作,代碼簡明扼要容易理解,絕對能讓你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
十多年的扶余網(wǎng)站建設經(jīng)驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。全網(wǎng)整合營銷推廣的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調(diào)整扶余建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)建站從事“扶余網(wǎng)站設計”,“扶余網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
css3三角形使用場景
我們知道有一個特效是span下拉列表,也就是說當鼠標放上一個div時,會出現(xiàn)原本隱藏的內(nèi)容或者二級菜單,這樣一個下拉列表會突出來一個小的三角形指向原本的div區(qū)域塊,如圖所示:
那么我們現(xiàn)在來總結一下,我們是如何寫出這些三角形的。
CSS3三角形實現(xiàn)原理
在css3中,我們主要使用的是一個transparent的屬性,意思是透明的,比如我們將字體設置為黑色會寫color:black,那么如果想把字體的顏色設置為透明,我們可以寫color:transparent。同理background-color:transparent可以設置背景為透明。
三角形8種分類
我們根據(jù)三角形的位置分為8種:
triangle up,triangle down,triangle left,triangle right,triangle top left,triangle top right,triangle bottom left和triangle bottom right。
8種三角形實現(xiàn)實例
1.triangle up 上三角形
#triangle-up{ width:0; height:0; border-left:50px solid transparent; border-right:50px solid transparent; border-bottom:100px solid black; }
2.triangle down 下三角形
#triangle-down{ width:0; height:0; border-left:50px solid transparent; border-right:50px solid transparent; border-top:100px solid black; }
3.triangle left 左三角形
#triangle-left{ width:0; height:0; border-top:50px solid transparent; border-bottom:50px solid transparent; border-right:100px solid black; }
4.triangle right 右三角形
#triangle-right{ width:0; height:0; border-top:50px solid transparent; border-bottom:50px solid transparent; border-left:100px solid black; }
5.triangle top left 左上三角形
#triangle-topleft{ width:0; height:0; border-top:100px solid black; border-right:100px solid transparent; }
6.triangle top right 右上三角形
#triangle-topright{ width:0; height:0; border-top:100px solid black; border-left:100px solid transparent; }
7.triangle bottom left 左下三角形
#triangle-bottomleft{ width:0; height:0; border-bottom:100px solid black; border-right:100px solid transparent; }
8.triangle bottom right 右下三角形
#triangle-bottomright{ width:0; height:0; border-bottom:100px solid black; border-left:100px solid transparent; }
大致的效果如圖所示:
看完上述內(nèi)容,你們掌握css3實現(xiàn)三角形的方法了嗎?如果還想學到更多技能或想了解更多相關內(nèi)容,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!