分分鐘搞定 CSS 中令你困擾的各種三角,搞定css

來源:互聯網
上載者:User

分分鐘搞定 CSS 中令你困擾的各種三角,搞定css

 

話不多說,直接

.triangle-one {
display: inline-block;
border-top: 50px red solid;
border-right: 50px green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-six {
display: inline-block;
border: 50px transparent solid;
border-bottom: 50px yellow solid;
}
.triangle-eight {
display: inline-block;
border: 50px transparent solid;
border-left: 30px yellow solid;
border-bottom: 0;
}

利用border覆蓋屬性:

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style>        .triangle-one {            display: inline-block;            border-top: 50px red solid;            border-right: 50px green solid;            border-bottom: 50px yellow solid;            border-left: 50px blue solid;        }        .triangle-two {            display: inline-block;            border-top: 0 red solid;            border-right: 50px green solid;            border-bottom: 50px yellow solid;            border-left: 50px blue solid;        }        .triangle-stree {            display: inline-block;            border-top: 50px red solid;            border-right: 0 green solid;            border-bottom: 50px yellow solid;            border-left: 50px blue solid;        }        .triangle-four {            display: inline-block;            border-top: 50px red solid;            border-right: 0 green solid;            border-bottom: 0 yellow solid;            border-left: 50px blue solid;        }        .triangle-five {            display: inline-block;            border: 50px transparent solid;            border-top: 50px red solid;        }        .triangle-six {            display: inline-block;            border: 50px transparent solid;            border-bottom: 50px yellow solid;        }        .triangle-seven {            display: inline-block;            border: 50px transparent solid;            border-top: 60px red solid;            border-right: 0;        }        .triangle-eight {            display: inline-block;            border: 50px transparent solid;            border-left: 30px yellow solid;            border-bottom: 0;        }    </style></head><body>    <div class="triangle-one"></div>    <div class="triangle-two"></div>    <div class="triangle-stree"></div>    <div class="triangle-four"></div>    <div class="triangle-five"></div>    <div class="triangle-six"></div>    <div class="triangle-seven"></div>    <div class="triangle-eight"></div></body></html>

  

 

 類似這樣的尖角都是這樣做:

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style>        .back {            width: 1000px;            height: 1000px;            margin: 0 auto;            background-color: #ddd;            position: relative;        }        .back-in {            position: absolute;            width: 1020px;            height: 45px;            left: -20px;            top: 50px;            background-color: #2F4F4F;        }        .back-img {            border: 20px solid transparent;            border-top: 10px solid dimgrey;            border-right: 0;            display: inline-block;            position: absolute;            top: 95px;            left: -20px;        }        .back-font {            line-height: 9px;            margin-left: 30px;            color: white;        }    </style></head><body>    <div class="back">        <div class="back-in"><h3 class="back-font">妹子求關注 ^.^</h3></div>        <div class="back-img"></div>    </div></body></html>

                                                                                                                                                                                                                                                                                                                                                                                                                                                          小圖片可以去http://www.bootcss.com/p/font-awesome/ 下載第三方模組,

對應的是unicode編碼圖片

Font Awesome為您提供可縮放的向量表徵圖,您可以使用CSS所提供的所有特性對它們變更,包括:大小、顏色、陰影或者其它任何支援的效果。

匯入方式:

<link href="../font-awesome/css/font-awesome.css" type="text/css" rel="stylesheet">



                                                                                                                                                                                                      

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.