具有类 call-img
的图像应该不会 float ,因为我为它使用了 clear:both
。但它仍然如此。
HTML:
<header>
<img class="logo-img" src="images/logo.png">
<div class="topnav-link">
<span>Menu </span>
<img class="menu-img" src="images/menu.png">
</div>
<img class="call-img" src="images/call.png">
</header>
CSS:
header {
padding-top: 2.5em;
}
.logo-img {
float: left;
width: 130px;
}
.menu-img {
width: 20px;
}
.topnav-link {
float: right;
color: white;
font-size: .8em;
}
.menu-img,
.topnav-link span {
vertical-align: middle;
}
.call-img {
display: inline-block;
clear: both;
align: center;
}
最佳答案
将CSS更改为
.call-img {
display: block;
clear: both;
text-align: center;
}
关于html - 为什么我的图像在使用 clear :both? 后仍然 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36530062/