介紹
今天,我們要學習如何使用簡單的CSS來創建不同類型的平面圖形。
使用代碼
矩形
.rectangle { width: 250px; height: 150px; background-color: #6DC75F; } <div></div>
三角形
.triangleUp { border-left: 75px solid transparent; border-right: 75px solid transparent; border-bottom: 150px solid #6DC75F; width: 0; height: 0; } <div class="triangleUp"></div>
橢圓形
.oval { width: 300px; height: 150px; background: #6DC75F; -moz-border-radius: 150px / 75px; -webkit-border-radius: 150px / 75px; border-radius: 150px / 75px; } <div class="oval"></div>
月牙形
.moon { width: 150px; height: 150px; border-radius: 50%; box-shadow: 15px 15px 0 0 green; } <div class="moon"></div>
樹葉
.leaf { border-radius: 5px 300px 3px 300px; background: #6DC75F; width: 150px; height: 150px; } <div class="leaf"></div>
興趣點
CSS能讓你完成很多令人驚艷的事情…祝大家編碼愉快!
原文:How to create different shapes in html using css 譯文:codeceo
掃碼二維碼 獲取免費視頻學習資料
- 本文固定鏈接: http://www.wangchenghua.com/post/4367/
- 轉載請注明:轉載必須在正文中標注并保留原文鏈接
- 掃碼: 掃上方二維碼獲取免費視頻資料
查 看2022高級編程視頻教程免費獲取