怎么样设置图片高宽度不影响其他元素
来源:3-17 编程练习
慕仰8079247
2020-02-02 14:56:01
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
/* 在此处补充代码*/
*{
margin:0;
padding:0;
list-style:none;
}
header{
background:black;
display:flex;
justify-content:space-around;
align-self:center;
}
.logo img{
height:60px;
width:100px;
}
.nav{
color:#fff;
display: flex;
align-self:center;
width:320px;
justify-content:space-between;
}
.login{
display:flex;
align-self: center;
justify-content:space-between;
width:200px;
}
.login input{
padding:3px 10px;
font-size:20px;
cursor:pointer;
background:orange;
border-radius: 5px;
border:none;
}
section{
display:flex;
justify-content: space-around;
flex-wrap: wrap;
}
.section{
width: 35%;
height: 150px;
background:green;
display: flex;
margin-top: 10px;
justify-content: space-around;
}
.box{
display:flex;
flex-direction:column;
justify-content: space-around;
}
</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回答
好帮手慕糖
2020-02-03
同学你好,关于你的问题,回答如下:
1、是指顶部logo图片吗?这是因为顶部没有设置固定的高度,高度是由图片撑开的,所以图片高度改变的时候,顶部导航条的高度也会改变。
宽度是因为其余两部分要分配省下的空间,而图片的宽高决定了省下的空间是多少,所以也会有区别。
建议:这里可以像当前这样设置固定的宽高不改变即可。或者不设置宽高,直接使用图片本身的宽高。
2、另,“加入购物车”这里,应该是个按钮,建议:给shopping这个类添加样式。
如果我的回答帮助了你,欢迎采纳,祝学习愉快~
相似问题
回答 2