为了账号安全,请及时绑定邮箱和手机立即绑定

用div画圣诞树 两个三角形怎么合在一起?

用div画圣诞树 两个三角形怎么合在一起?

妙蛙不开花 2017-11-02 18:34:34
要的效果如下!!请各位帮忙!
查看完整描述

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>


查看完整回答
反对 回复 2017-11-10
?
什么名字都被占用

TA贡献17条经验 获得超3个赞

用绝对定位做

查看完整回答
反对 回复 2017-11-02
  • 妙蛙不开花
    妙蛙不开花
    有代码吗
  • 什么名字都被占用
    什么名字都被占用
    方便的话,你把代码复制给我,我来改一下哦
  • 妙蛙不开花
    妙蛙不开花
    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> #trip1{ 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); } #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); } </style> </head> <body> <div> <div id="trip1"></div> <div id="trip2"></div> </div> </body> </html>
点击展开后面1
  • 2 回答
  • 0 关注
  • 1558 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信