老师,有地方需要优化吗?

来源:3-17 编程练习

weixin_慕斯卡3172839

2021-01-16 16:41:05

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title></title>

    <style>

     /* 在此处补充代码*/

     *{

      padding:0;

      margin:0;

      list-style: none;

     }

     header{

      display: flex;

      background: #000;

      color: #fff;

      justify-content: space-around;

      align-items: center;

     }

     .nav{

      flex:2;

      display: flex;

      justify-content: space-around;

     }

     .logo{

      flex:1;

     }

     li{

      font-size: 24px;

     }

     .login{

      flex:1;

      /*width:200px;*/

      display: flex;

      justify-content: center;

     }

     .login input{

      font-size: 22px;

      border:none;

      background: orange;

      border-radius: 5px;

      color: #fff;

      padding:5px;

      margin-right: 20px;

     }

     section{

      height: 300px;

      display: flex;

      flex-wrap: wrap;

      justify-content: space-around;

      align-content: space-around; 

     }

     .section{

      border-radius: 5px;

      background: #0cc;

      width:45%;

      height: 45%;

      display: flex;

     }

    .box{

    width: 70%;

    display: flex;

    flex-direction: column;

align-content: space-around;

    }

    .box p,.box div {

    display: flex;

    align-items: center;

    flex:1;

    padding: 0 15px;

    }

    .shopping{

    width: 30%;

    display: flex;

    justify-content: center;

    align-items: center;

    }

    .btn{

    background-color: orange;

    padding: 10px 15px;

    border-radius: 5px;

    color: #fff;

    font-weight: bold;

    }

    </style>

</head>

<body>

<!-- 头部 -->

   <header>

     <div class="logo">

       <img src="http://climg.mukewang.com/59197ab000014f1503000100.jpg" alt="">

     </div>

       <ul class="nav">

         <li>课程</li>

         <li>路径</li>

         <li>猿问</li>

         <li>手记</li>

       </ul>     

     <div class="login">

       <input type="button" value="登录">

       <input type="button" value="注册">

     </div>

   </header>

<!-- 主体内容 -->

   <section>

    <div class="section">

      <div class="box">

        <p>《前端小白入门手册》</p>

        <div>适用人群:没有任何前端基础的小白</div>

        <div>费用:¥499</div>

      </div>

      <div class="shopping">

        <div class="btn">加入购物车</div>

      </div>

    </div>

    <div class="section">

      <div class="box">

        <p>《HTML5月CSS3实现动态网页》</p>

        <div>适用人群:有html和css基础的童鞋</div>

        <div>费用:¥599</div>

      </div>

      <div class="shopping">

        <div class="btn">加入购物车</div>

      </div>

    </div>

    <div class="section">

      <div class="box">

        <p>《HTML5月CSS3实现动态网页》</p>

        <div>适用人群:有html和css基础的童鞋</div>

        <div>费用:¥599</div>

      </div>

      <div class="shopping">

        <div class="btn">加入购物车</div>

      </div>

    </div>

    <div class="section">

      <div class="box">

        <p>《HTML5月CSS3实现动态网页》</p>

        <div>适用人群:有html和css基础的童鞋</div>

        <div>费用:¥599</div>

      </div>

      <div class="shopping">

        <div class="btn">加入购物车</div>

      </div>

    </div>

    </section>  

</body>

</html>


写回答

1回答

好帮手慕星星

2021-01-16

同学你好,代码布局是可以的,样式上还可以进行优化:

1、logo与父盒子之间由间隙

http://img.mukewang.com/climg/6002c90109888a9a04490142.jpg

这是因为图片为行内元素,有文字特性,默认存在间隙。建议将图片设置为块元素

http://img.mukewang.com/climg/6002c93a090ba07603800113.jpg

祝学习愉快!

1

0 学习 · 6815 问题

查看课程