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

为什么我的块元素会跟上面文字块元素重叠

为什么我的块元素会跟上面文字块元素重叠

Miss时刻想你 2017-08-16 23:15:46
*{ padding: 0; margin: 0; } /*网页头部*/ .header{ width: 100%; height: 100px; background-color: #07cbc9; position: fixed; z-index: 9; } .header .logo img{ float: left; height: 48px; width: 260px; margin-top: 26px; margin-left: 100px; } .header .h-nav{ float: right; height: 100px; } .header .h-nav ul{ margin-right: 50px; } .header .h-nav ul li{ width: 105px; float: left; list-style: none; font-size: 20px; color: #fff; text-align: center; line-height: 100px; font-family: "微软雅黑"; } .header .h-nav ul li:hover{ cursor: pointer; background-color: #000; } /*banner图*/ .banner .pic img{ width: 100%; height: 700px; position: relative; padding-top: 100px; } .banner .shade{ position: absolute; opacity: 0.5; width: 100%; height: 700px; background-color: #000; z-index: 1; top: 100px; } /*表单*/ .banner .form-menu{ width: 700px; height: 300px; z-index: 2; text-align: center; position: absolute; top: 250px; left: 50%; margin-left: -350px; } .banner .form-menu input,button{ background-color: transparent; color: #999999; border: thin solid; width: 400px; height: 30px; margin-top: 20px; } .banner .form-menu textarea{ width: 400px; background-color: transparent; margin-top: 20px; color: #999999; } .banner .form-menu button{ width: 150px; } .banner .form-menu input:hover{ border-color: #07cbc9; } .banner .form-menu textarea:hover{ border-color: #07cbc9; } .banner .form-menu button:hover{ background-color: #07cbc9; color: #fff; border-style: none; } /*网页主体*/ .main{ width: 100%; height: auto; font-family: "微软雅黑"; } .main .about{ width: 90px; height: 30px; font-weight: bolder; font-size: 25px; padding-top: 20px; padding-bottom: 10px; line-height: 30px; margin: 0 auto; } .main hr{ width: 20px; border-color: #07cbc9; margin: 0 auto; text-align: center; } .main .m-word{ width: 400px; height: 20px; text-align: center; margin: 0 auto; padding-top: 10px; color: #999999; font-weight: bold; } .main .m-pic{ width: 100%; height: 250px; text-align: center; margin-top: 20px; } .main .m-pic img{ width: 420px; height: 250px; } /*网页底部*/ /*清除浮动*/ .clear{ clear: both; } <body> <!--网页头部--> <div class="header"> <div class="logo"> <img src="img/logo.png" alt="logo" /> </div> <div class="h-nav"> <ul> <li>HOME</li> <li>ABOUT</li> <li>GALLERY</li> <li>FACULTY</li> <li>EYENUTS</li> <li>CONTACT</li> </ul> </div> <div class="clear"></div> </div> <!-- banner图 --> <div class="banner"> <div class="pic"> <img src="img/banner3.jpg" /> </div> <!-- 遮罩 --> <div class="shade"></div> <!-- 表单 --> <div class="form-menu"> <div class="menu-word"> <input type="text" name="name" value="&nbsp;&nbsp;your Name"> </div> <div class="menu-word"> <input type="text" name="password" value="&nbsp;&nbsp;your password" size="16"> </div> <div class="menu-word"> <input type="text" name="email" value="&nbsp;&nbsp;your Email"> </div> <div class="menu-word"> <textarea type="text" name="recommend" placeholder="&nbsp;To introduce myself" rows="10"></textarea> </div> <button>Sure to submit</button> </div> </div> <!--网页主体--> <div class="main"> <div class="about">ABOUT</div> <hr/> <div class="m-word"> He edited the report that was to be presented to the committee at the hearing. They referred their plan to the management.  </div> <div class="m-pic"> <img src="img/bb3.jpg" align="child" /> </div> </div> <!--网页底部--> <div class="footer"></div> </body>
查看完整描述

3 回答

已采纳
?
信者得救

TA贡献22条经验 获得超10个赞

因为你把包含文字的父元素那个div的 width 和height设置的太小了,容不下文字了,它就会超出父元素的范围。因为设置了父元素高度,父元素就不会根据子元素调整高度了。

你直接把那个div的height删掉就可以。

查看完整回答
1 反对 回复 2017-08-17
?
qq_安安_17

TA贡献49条经验 获得超52个赞

//img1.sycdn.imooc.com//5994eaf300019e2706460146.jpg

margin值不够,20px不足以使两个子元素分离

//img1.sycdn.imooc.com//5994eaf400015dc606110471.jpg


查看完整回答
反对 回复 2017-08-17
?
Miss时刻想你

TA贡献1条经验 获得超0个赞

我指的是那个小图片和文字重叠了。。我这两个都是块元素,也没有设置过浮动和定位。

查看完整回答
反对 回复 2017-08-16
  • 3 回答
  • 0 关注
  • 2565 浏览
慕课专栏
更多

添加回答

举报

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