老师,检查一下,有没有完善的地方,谢谢
来源:3-17 编程练习
superman888
2020-08-22 11:31:34
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{margin: 0;padding: 0; }
header{width: 100%;height: 80px;display: flex;justify-content: space-around;
background: black;}
header .logo{width: 200px;}
header .logo img{width: 240px;height: 80px;}
header .nav{width: 400px;display: flex;justify-content: space-between;
align-items: center;}
header .nav>li{list-style: none;font-size: 24px;color: white;}
header .login{width: 150px;display: flex;justify-content: space-around;
align-items: center;}
header .login input{font-size: 18px;padding: 2px;background: orange;
border: none;color: white;border-radius: 4px; }
section{
width: 100%;height: 150px;
display: flex;justify-content: space-around;
}
section .section{height: 100%;width: 620px;display: flex;justify-content: space-around;
border-radius: 14px;background: rgb(173,216,230);margin-top: 20px;}
section .section .box{height: 100%;display: flex;flex-direction: column;
justify-content: space-around;font-weight: bold;}
section .section .shopping{display: flex;align-items: center;}
section .section .shopping .btn{width: 80px;height: 20px;background: orange;
color: white;font-weight: bold;padding: 10px 10px;border-radius: 6px;}
</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>
</section>
</body>
</html>
1回答
同学你好,代码中有如下问题:
1. logo图的父元素,没有完全包裹图片:

建议不给父元素设置宽度,宽度由内容撑开,如下:

2. 优化建议:按钮的间距可增大些,让样式更好看:


3. 添加4个内容后,内容不换行显示:

可设置内容换行,如下:

另外,子元素的宽度可以设置成百分比:

如果我的回答帮到了你,欢迎采纳,祝学习愉快!
相似问题