怎麼利用CSS3繪製三角形

來源:互聯網
上載者:User

標籤:

最近三角形挺火,很多地方都能碰到,如網頁,,或者QQ空間的時間軸等地方都能看到,而且這些並不是圖片插入進去的,那就需要用CSS來做了

<p class="bbb">111111111111</p><br/><div class="triangle-up">     <!--向上的三角--> </div><br/><div class="triangle-down">    <!--向下的三角--> </div><div class="triangle-left">    <!--向左的三角--> </div><div class="triangle-right">    <!--向右的三角--> </div>
 1 <style> 2     .bbb { 3         width: 300px; 4         height: 200px; 5         background: forestgreen; 6         margin: auto; 7         padding: 10px; 8         color: #FFFFFF; 9         position: relative;10 11     }12     .bbb:before {13         content: ‘‘;14         display: block;15         position: absolute;16         left: 20px;17         top: -10px;18         width: 0;19         height: 0;20         border: 10px solid transparent;21         border-top: 0 none;22         border-bottom-color: forestgreen;23     }24     .triangle-up {25         width: 0;26         height: 0;27         border-left: 30px solid transparent;28         border-right: 30px solid transparent;29         border-bottom: 30px solid green;30     }31     .triangle-down {32         width: 0;33         height: 0;34         border-left: 20px solid transparent;35         border-right: 20px solid transparent;36         border-top: 20px solid blue;37     }38     .triangle-left {39         width: 0;40         height: 0;41         border-top: 20px solid transparent;42         border-bottom: 20px solid transparent;43         border-right: 20px solid red;44     }45     .triangle-right {46         width: 0;47         height: 0;48         border-top: 20px solid transparent;49         border-bottom: 20px solid transparent;50         border-left: 20px solid green;51     }52     .triangle-up, .triangle-down, .triangle-left, .triangle-right{  display: block; margin: auto;}53     </style>

:

怎麼利用CSS3繪製三角形

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.