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 关注
- 1599 浏览
相关问题推荐
添加回答
举报