2-9提问 感觉自己的代码太冗长了。。。而且还有很多没打成要求的 请大家帮我看看 谢谢

2-9提问 感觉自己的代码太冗长了。。。而且还有很多没打成要求的 请大家帮我看看 谢谢

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title></title>
  <style type="text/css">
    /*此处写代码*/
    *{margin:0;
        padding:0;
    }
    .bg{background:black;
        width:100%;
        height:100px;
        position:absolute;
        top: 0;
            }
    .logo{
        background:url(http://img1.sycdn.imooc.com/climg//58c0d2d900016ce303000100.png) no-repeat;
        width:30%;
        height:80px;
        float:left;

    }
    .dht{
      width:10%;
      height: auto;
      color: white;
      float: right;
      font-size: 20px;
      line-height: 100px;
      margin-left:30px;
      text-align: center; 
      cursor: pointer;         
    }
    .dht:nth-child(4){margin-left: 40px;}
    .wb{
      background-color: black;
      width: 100%;
      height: 100px;
      bottom: 0;
     position: absolute;

      
    }
   .no{width:50%;
   	margin: 0 auto;
   	height: 100px;

   }
    .ljq{color: white;
      line-height: 100px;
      width: 15%;
      float: left;    

  }
  .wbqy{width: 100%;
  	    height: 3000px;
  	    background-color:#8EE5EE;
  	    top: 100px;	
  	    }
  	.wby{width: 80%;
  		height: 3000px;
  	background-color:#8EE5EE;
  	margin: 100px auto
  	 }    

  .left{width: 60%;
  	    float: left;
  	    	top: 100px;
  	    	height: 500px;}
  	.right {float: right;top: 100px;
  		width:  40%;}
  	h1{color:black;

  }
  span{background-color: #FF6347;}
 ul {list-style-type : none;}
 .baba{margin-top: 10%;width: 90%;height: 50%;}
 li{margin: 10px;}
 .chill{margin: 10px}
 .baba1{margin-top: 80px;}
  </style>  
</head>
<body>
  <!-- 此处写代码 -->
  <div class="bg">
      <div class="logo"></div>
      <div class="dht">手记</div>
      <div class="dht">猿问</div>
      <div class="dht">实战</div>
      <div class="dht">职业路径</div>
      <div class="dht">课程</div>
  </div>
  <div class="wbqy">
  	<div class="wby">
  	<div class="left">

       <ul class="baba" ><div class="chill">课程推荐</div>
       	<li><span>职业路径</span>&nbsp;&nbsp;&nbsp;HTML5与CSS3实现动态网页</li>
       	<li><span>职业路径</span>&nbsp;&nbsp;&nbsp;零基础入门Android</li>
       	<li><span>职业路径</span>&nbsp;&nbsp;&nbsp;ios基础语法与常用控件</li>
       	<li><span>职业路径</span>&nbsp;&nbsp;&nbsp;hp入门开发</li>
       	<li><span>职业路径</span>&nbsp;&nbsp;&nbsp;JAVA入门开发</li>
       </ul>
  	</div>
  	<div class="right">
  		
       <ul class="baba1" ><div class="chill">相关课程</div>
    		<li>HTML&nbsp;&nbsp;&nbsp;CSS&nbsp;&nbsp;&nbsp;Javascirpt</li>
    		<li>HTML5&nbsp;&nbsp;&nbsp;CSS3&nbsp;&nbsp;&nbsp;Jquery</li>
    		<li>移动端基础&nbsp;&nbsp;&nbsp;移动端app开发</li>
       </ul>
  	</div>
  </div>
  </div>
 
  <div class="wb">
     <div class="no">
        <div class="ljq">网站首页</div>
        <div class="ljq">企业合作</div>
        <div class="ljq">人才招聘</div>
        <div class="ljq">联系我们</div>
        <div class="ljq">常见问题</div>
        <div class="ljq">友情链接</div>
      </div> 
  </div>
   
</body>
</html>


正在回答

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

2回答

测试了你的代码,有几个小问题:

1、如果想要设置顶部和底部固定在浏览器上下的话,需要的是position:fixed;不是固定定位。

2、导航链接建议使用列表来写会方便一些,不需要每个要添加class名字。

下面是给你修改的代码,可以看一下哦:

<!DOCTYPE html>

<html>


<head>

    <meta charset="UTF-8">

    <title></title>

    <style type="text/css">

    * {

        margin: 0;

        padding: 0;

    }


    ul,

    li {

        list-style: none;

    }


    .bg {

        background: black;

        width: 100%;

        height: 100px;

        position: fixed;

        top: 0;

        left: 0;

    }


    .logo {

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

        width: 30%;

        height: 100px;

        float: left;

    }


    .dht {

        float: right;

        width: 30%;

    }


    .dht li {

        float: left;

        height: 100px;

        line-height: 100px;

        margin-right: 55px;

        color: #fff;

    }


    .wb {

        background-color: black;

        width: 100%;

        height: 100px;

        bottom: 0;

        left: 0;

        position: fixed;

    }


    .wb ul {

        width: 884px;

        margin: 0 auto;

        height: 100px;

    }


    .wb ul li {

        color: white;

        line-height: 100px;

        float: left;

        margin-right: 100px;

    }


    .wb ul li:last-of-type {

        margin-right: 0;

    }


    .wbqy {

        width: 100%;

        height: 1000px;

        background-color: #8EE5EE;

        top: 100px;

    }


    .wby {

        width: 80%;

        height: 1000px;

        background-color: #8EE5EE;

        margin: 100px auto

    }


    .left {

        width: 60%;

        float: left;

        top: 100px;

        height: 500px;

    }


    .right {

        float: right;

        top: 100px;

        width: 40%;

    }


    h1 {

        color: black;

    }


    span {

        background-color: #FF6347;

    }


    ul {

        list-style-type: none;

    }


    .baba {

        margin-top: 10%;

        width: 90%;

        height: 50%;

    }



    .chill {

        margin: 10px

    }


    .baba1 {

        margin-top: 80px;

    }

    </style>

</head>


<body>

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

    <div class="bg">

        <div class="logo"></div>

        <ul class="dht">

            <li>手记</li>

            <li>猿问</li>

            <li>实战</li>

            <li>手记</li>

            <li>职业路径</li>

            <li>课程</li>

        </ul>

    </div>

    <div class="wbqy">

        <div class="wby">

            <div class="left">

                <ul class="baba">

                    <div class="chill">课程推荐</div>

                    <li><span>职业路径</span>&nbsp;&nbsp;&nbsp;HTML5与CSS3实现动态网页</li>

                    <li><span>职业路径</span>&nbsp;&nbsp;&nbsp;零基础入门Android</li>

                    <li><span>职业路径</span>&nbsp;&nbsp;&nbsp;ios基础语法与常用控件</li>

                    <li><span>职业路径</span>&nbsp;&nbsp;&nbsp;hp入门开发</li>

                    <li><span>职业路径</span>&nbsp;&nbsp;&nbsp;JAVA入门开发</li>

                </ul>

            </div>

            <div class="right">

                <ul class="baba1">

                    <div class="chill">相关课程</div>

                    <li>HTML&nbsp;&nbsp;&nbsp;CSS&nbsp;&nbsp;&nbsp;Javascirpt</li>

                    <li>HTML5&nbsp;&nbsp;&nbsp;CSS3&nbsp;&nbsp;&nbsp;Jquery</li>

                    <li>移动端基础&nbsp;&nbsp;&nbsp;移动端app开发</li>

                </ul>

            </div>

        </div>

    </div>

    <div class="wb">

        <ul>

            <li>网站首页</li>

            <li>企业合作</li>

            <li>人才招聘</li>

            <li>联系我们</li>

            <li>常见问题</li>

            <li>友情链接</li>

        </ul>

    </div>

</body>


</html>

祝学习愉快~~

  • AiChiRol 提问者 #1
    谢谢你
    2018-03-06 15:00:15
  • AiChiRol 提问者 #2
    您好,想问问sublimetext3有没有什么插件,可以排版的,每次写完都感觉自己写的好乱( p′︵‵。)
    2018-03-06 15:03:11
  • 好帮手慕星星 回复 提问者 AiChiRol #3
    可以使用ctrl+shift+p安装HTML/CSS/JS Prettify这个插件,代码格式化的。
    2018-03-06 15:14:01
好帮手慕星星 2018-03-06 15:52:54

有两种方法:

1、在属性的地方打开:

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

点击Plugin Options-Default选项,打开:

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

2、在代码页面中右击鼠标,出现菜单,

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

自己测试下。

  • 提问者 AiChiRol #1
    请问这个是需要装nod.js吗
    2018-03-06 15:56:10
  • 好帮手慕星星 回复 提问者 AiChiRol #2
    是的哦,在网页上面下载node.js,直接默认安装路径就可以了。安装之后重启sublime编辑器,再试试。
    2018-03-06 16:03:24
  • 提问者 AiChiRol 回复 好帮手慕星星 #3
    可以了,谢谢你(。•̀ᴗ-)✧
    2018-03-06 16:06:42
问题已解决,确定采纳
还有疑问,暂不采纳

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

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

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

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