老师检查一下吧

来源:5-2 编程练习

光aaaaand影

2019-06-25 10:52:40

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
            *{
                padding:0;
                margin:0;
            }
      /*头部*/
      header{
          display:flex;
          justify-content:space-around;
          align-items:center;
          background:#000;
      }
      ul{
          display:flex;
          justify-content:space-between;
          list-style:none;
          width:300px;
          color:#fff;
      }
      .login{
          width:100px;
          display:flex;
          justify-content:space-between;
      }
      .login input{
            padding:5px;
          color:#fff;
          background:orange;
          border-radius:5px;
          border:none;
      }
        /* 主体 */
        section{
            display:flex;
            flex-wrap: wrap;
            justify-content:space-around;
        }
        .section{
            width:500px;
            height:150px;
            margin-top:20px;
            background:lightblue;
            border-radius:10px;
            display:flex;
            align-items:center;
            justify-content:space-between;
            padding:0 50px;
        }
        .btn{
            background:orange;
            color:#fff;
            padding:10px;
            border-radius:5px;
            font-weight:bold;
        }
        .btn:hover{
            color:orange;
            background:lightblue;
            cursor:pointer;
        }
        .box{
            height:150px;
            font-weight:bold;
            display:flex;
            flex-direction:column;
            justify-content:space-around;
        }
    </style>
</head>
<body>
   <header>
     <div class="logo">
       <img src="http://climg.mukewang.com/59feb59700019dab01910057.png" 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>《前端小白入门手册》</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>
    </section>  
</body>
</html>

还有什么别的办法吗

写回答

1回答

好帮手慕夭夭

2019-06-25

你好同学, 如下4个小盒子设置固定宽度,当在比较分辨率大的浏览器显示,一行就放下3个,布局就不对了

http://img.mukewang.com/climg/5d11bc2a00018ec319170390.jpg

使用百分比设置宽度:

http://img.mukewang.com/climg/5d11bc6d00013eec02670103.jpg

同学的方式已经很不错了,其他的方法与这个差不多。当然,问答区域有很多同学分享了自己的代码,同学可在问答区域学习一下哦。

祝学习愉快,望采纳。

0

0 学习 · 5012 问题

查看课程