CSS通過邊框border-style來寫小三角,cssborder-style

來源:互聯網
上載者:User

CSS通過邊框border-style來寫小三角,cssborder-style

<!DOCTYPE html>
/*直接複製代碼即可在瀏覽器驗證*/

<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
/*盒子的樣式*/
.box {
position: relative;
margin: 20px auto;
height: 200px;
width: 200px;
background: rgba(0, 0, 0, 0.5);
}
/*利用border-style實現*/
.drop-down {
position: absolute;
top: 10px;
left: 10px;
height: 0;
width: 0;
border: 3px;
/*style依次是上邊框、右、下、左*/
border-style: solid dashed dashed dashed;
/*想實現向下的三角就把上邊框設定為實現其餘幾個邊框都是虛線並且顏色設定為透明*/
border-left-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
color: #fff;
}

/*再來寫個三角向右的例子*/
.right {
position: absolute;
top: 10px;
left: 30px;
height: 0;
width: 0;
border:10px;
border-style:dashed dashed dashed solid;
border-top-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
color: yellowgreen;
}


</style>
</head>
<body>
<!--先寫個盒子加上黑色背景,來和產生的小三角來做下對比-->
<div class="box">
<i class="drop-down"></i>
<i class="right"></i>
</div>

</body>
</html>



聯繫我們

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