请老师检查代码
来源:3-3 编程练习
一只小木马
2022-02-18 18:11:56
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> /* 在此处补充代码*/ *{ margin: 0; padding:0; } body{ height: 100vh; } header{ height: 60px; display: flex; justify-content: space-between; align-items: center; background-color: black; padding: 0 50px; } .logo{ height: 100%; } .logo img{ height: 100%; vertical-align: top; } .nav{ color: #fff; width: 50%; display: flex; justify-content: space-between; align-items: center; } .nav li{ flex-grow: 1; list-style: none; } .login{ display: flex; justify-content: space-between; align-items: center; } .login input{ margin-right: 20px; border: none; border-radius: 2px; background-color:orange; color: #fff; font-size: 14px; } section{ display: flex; flex-wrap: wrap; justify-content: space-around; padding-top: 20px; } .section{ width: 40%; border-radius: 10px; background-color: turquoise; margin-bottom: 20px; padding:15px 30px 15px 30px; display: flex; justify-content: space-between; align-items: center; } .section .box{ font-size: 14px; display: flex; flex-direction: column; justify-content: center; } .section .box p{ flex-grow: 1; margin-bottom: 15px; } .section .box div{ flex-grow: 1; margin-bottom: 15px; } .section .box div:last-child{ margin-bottom: 0; } .section .shopping .btn{ width: 80px; height: 30px; background-color: orange; border-radius: 4px; font-size: 12px; display: flex; justify-content: center; align-items: center; color: #fff; } </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>《从H5网页开发到移动端响应式开发》</p> <div>适用人群:有html、css、js、jQ基础的童鞋</div> <div>费用:¥599</div> </div> <div class="shopping"> <div class="btn">加入购物车</div> </div> </div> <div class="section"> <div class="box"> <p>《从H5网页开发到移动端响应式开发》</p> <div>适用人群:有html、css、js、jQ基础的童鞋</div> <div>费用:¥599</div> </div> <div class="shopping"> <div class="btn">加入购物车</div> </div> </div> </section> </body> </html>
1回答
好帮手慕久久
2022-02-18
同学你好,代码有如下问题:
1、导航文字在自己的父元素中位置不正确:
正确效果如下:
修改如下:
2、按钮在自己的父元素中,也没有均布:
建议调整marign-right为左右对称margin:
另外,文字紧挨按钮边框,样式不好看,建议添加padding:
3、div和p标签宽度会自动充满父元素,如下样式没有实际效果,可以删除:
祝学习愉快!