效果图貌似实现了,不知道代码是否规范,有没有需要注意的地方呢

效果图貌似实现了,不知道代码是否规范,有没有需要注意的地方呢

<!DOCTYPE html>

<html>

<head>

  <meta charset="UTF-8">

  <title></title>

  <style type="text/css">

    /*此处写代码*/

    *{

        margin:0;

        padding:0;

    }

    .con{

        width:1200px;

        height:100px;

        background:black;

        position:fixed;

        top:0px;left:50%;

        margin-left:-600px;

        overflow:hidden;

        z-index: 9999;

    }

    .navback{

        width:300px;height:100%;

        background:url(
http://img1.sycdn.imooc.com/climg//58c0d2d900016ce303000100.png
);

        float:left;

    }

    div.con:hover .navback{

     cursor: pointer;

    }

    .nav-1{

     width:600px;height:100px;

     float:right;margin-right:20px;

    }

    .nav-1 ul{

        list-style-type: none;

    }

    .nav-1 ul li{

     height:100px;

     margin:auto 20px;

     font:20px "微软雅黑";color:white;

        line-height:100px;

  float:right;

    }

     .nav-1:hover ul li{

     cursor: pointer;

     }

    .footer{

        width:1200px;

        height:100px;

        background:black;

        position:fixed;

        bottom:0px;left:50%;

        margin-left:-600px;

        overflow:hidden;

    }

 .footer ul{

  width:1000px;

  margin:0 auto; 

        list-style-type: none;

        text-align: center;

    }

    .footer ul li{

     height:100px;

     margin:auto 20px;

     font:20px "微软雅黑";color:white;

        line-height:100px;

  display: inline-block;

    }

     .footer:hover ul li{

     cursor: pointer;

     }

     .pic{

      width:1200px;height:1300px;

      position:relative;

      top:100px;left:50%;

      margin-left:-600px; 

     }

     .pic1{

      width:1200px;height:400px;

      background: url(
http://img1.sycdn.imooc.com/climg//58c0eda50001e12416000480.jpg
) no-repeat top center;

     }

     .pic2{

  width:1200px;height:400px;

      background: url(
http://img1.sycdn.imooc.com/climg//58c0edb80001c9f216000480.jpg
) no-repeat;

     }

     .pic3{

  width:1200px;height:400px;

      background: url(
http://img1.sycdn.imooc.com/climg//58c0edc9000100d516000480.jpg
) no-repeat;

     }

  </style>

</head>

<body>

   <!-- 此处写代码 -->

   <div class="con">

   <div class="navback"></div>

   <div class="nav-1">

       <ul>

          <li>课程</li>

          <li>职业路径</li>

          <li>实战</li>

           <li>猿问</li>

           <li>手记</li>

       </ul>

   </div>

   </div>

 <div class=pic>

 <div class="pic1"></div>

 <div class="pic2"></div>

 <div class="pic3"></div>

 </div>

 <div class="footer">

   <ul>

          <li>网站首页</li>

          <li>企业合作</li>

          <li>人才招聘</li>

           <li>联系我们</li>

           <li>常见问题</li>

           <li>友情链接</li>

       </ul>

 </div>

</body>

</html>

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕星星 2018-11-30 09:44:51

li元素设置成了inline-block元素,给父元素ul设置text-align:center;就可以居中显示了,外层盒子不需要设置固定宽度以及margin居中显示,自己可以测试下。

好帮手慕星星 2018-11-29 16:21:19

1、页面没有全屏显示:

http://img1.sycdn.imooc.com//climg/5bff9f9000011d4e19190641.jpg

代码中设置了宽度为1200px,自己测试的时候可能是全屏显示的,但是每个显示器的分辨率不同,显示效果也会不同,所以建议同学设置各部分宽度为100%。

2、顶部右侧的导航文字位置反了:

http://img1.sycdn.imooc.com//climg/5bffa0220001b90f05250106.jpg

课程应该是第一个,所以每一项li应该设置左浮动,不是右浮动哦,建议重新调整下。

3、底部导航li已经设置了为inline-block元素,就可以一行显示,外层ul盒子就不需要设置固定宽度居中显示了,去掉即可:

http://img1.sycdn.imooc.com//climg/5bffa070000117df03050147.jpg

4、中间图片的优化:建议直接使img图片填充,在样式中统一设置即可:

http://img1.sycdn.imooc.com//climg/5bffa1450001fde810580137.jpg

http://img1.sycdn.imooc.com//climg/5bffa17400013f5005630478.jpg

自己完善测试下,祝学习愉快!

  • 提问者 土土的星 #1
    第三点 去掉ul盒子的margin值,底部导航还能居中显示吗?
    2018-11-29 22:27:16
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师