html - 为什么我的图像在使用 clear :both? 后仍然 float

标签 html css css-float

具有类 call-img 的图像应该不会 float ,因为我为它使用了 clear:both。但它仍然如此。

HTML:

<header>
    <img class="logo-img" src="images/logo.png">
    <div class="topnav-link">
        <span>Menu&nbsp;&nbsp;&nbsp;&nbsp;</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/

相关文章:

html - 将另一个 Div 堆叠在彼此之上

javascript - 不允许在可排序列表中排序,仅使用 connectWith 将它们移动到不同的可排序列表

html - 如何避免 CSS 影响动态添加的类

html - Firefox 无法滚动浏览带有隐藏滚动的元素中的导航键

css - 有没有办法减少小屏幕上显示的单选按钮数量,然后循环显示它们?

html - 如何防止 div 中的 float 中断? ( Bootstrap )

html - CSS - 组件透明度

javascript - Android 浏览器 html5 音频无法播放

css - 适合浏览器大小的全屏 div

css - 如何将 CSS 列扩展到可用空间?