看下有什么优化的地方

来源:3-17 编程练习

唯5

2021-04-18 14:23:30

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title></title>

    <style>

        *{

        padding: 0;

        margin:0;

        }

        li{

        list-style: none;

        }

        body{

        min-width: 900px;

        }

        header{

           width: 100%;

           height: 120px;

           background-color: black;

           color: white;

        display: flex;

        flex-direction:row;

        flex-wrap: nowrap;

        justify-content: space-around;

        align-items: center;

        }

        .logo{

          

          

        }

        .nav{

        width: 500px;

       

        display: flex;

        flex-direction: row;

        font-size: 20px;

        justify-content: space-around;

        }

        .login{

          

           display: flex;

           flex-flow: row nowrap;

        }

        .login input{

        background-color: orange;

        margin-left: 30px;

        width: 40px;

        height: 30px;

        line-height: 30px;

            color: white;

        border: none;

        }

        section{

        width: 100%;

        height: 300px;

        display: flex;

        flex-wrap: wrap;

        flex-direction: row;

            

        justify-content: space-around;

        align-items: center;

        }

        .section{

        flex-basis: 40%;

        height: 100px;

        background-color: #ACD8E6;

        border-radius: 5px;

        display: flex;

        justify-content: space-around;

        align-items: center;

        }

        .shopping{

        padding: 3px;

        background-color: orange;

        color: white;

        border-radius: 5px;

        }

    </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-04-18

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

1、图片为行内元素,有文字特性,默认存在间隙。可以将图片设置为块元素

http://img.mukewang.com/climg/607c027e090d6aae03190097.jpg

2、顶部右侧按钮可以添加圆角效果,会美观一些

http://img.mukewang.com/climg/607c029409afc32302440095.jpg

http://img.mukewang.com/climg/607c02ad09e1e62704270294.jpg

3、内容上下没有间隙

http://img.mukewang.com/climg/607c02bf0964329605810115.jpg

目前是内容撑起来的高度,建议给.box元素设置高度与父元素相等,然后添加flex,如下

http://img.mukewang.com/climg/607c0327094881a004880184.jpg


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

0

0 学习 · 6815 问题

查看课程