2 回答

TA貢獻17條經驗 獲得超3個贊
<!DOCTYPE html>
<html>
?<head>?
? <meta charset="UTF-8" />?
? <title>Document</title>?
? <style>
? ? ? /*子元素偏移是相對于父層.wrap來定位*/
? ? ? #trip1{ width: 0px; height: 0px; border-top: 50px solid rgba(200,200,200,0); border-right: 50px solid rgba(200,200,200,0); border-bottom: 50px solid green; border-left: 50px solid rgba(200,200,200,0);position: absolute;top: 0;left: 50%;margin-left: -50px; }?
? ? ? #trip2{ width: 0px; height: 0px; border-top: 100px solid rgba(200,200,200,0); border-right: 100px solid rgba(200,200,200,0); border-bottom: 100px solid green; border-left: 100px solid rgba(200,200,200,0); position: absolute;top:0px;left: 50%;margin-left: -100px;}
? ? /*設置父元素相對定位*/
? ?.wrap{width: 500px;height:300px;margin: 20px auto;position: relative;}?
? </style>?
?</head>?
?<body>?
? <div class="wrap">?
? ?<div id="trip1"></div>?
? ?<div id="trip2"></div>?
? </div>??
?</body>
</html>
- 2 回答
- 0 關注
- 1683 瀏覽
相關問題推薦
添加回答
舉報