html - 垂直对齐图像旁边的文本,CSS 不起作用

标签 html css

好吧,我已经查看了一堆类似的其他堆栈溢出问题,但似乎没有任何效果。我不知道为什么它不起作用一定是我没听清楚的愚蠢的事情。

我的 CSS

.how-right {
}
.how-right img {
    float:right;
    margin-left:20px;
    vertical-align:middle;
}
.how-left {
}

我的 HTML

<!-- Number 1 -->
<div style="height:259px;" class="how-right">
    <img src="img/how-it-works/num-1.PNG" width="267px" height="259px">
    <span> has a simple system to get you in shape in just 6 weeks.  And it's so easy to follow, even people who have never exercised before can do it.</span>
</div>

最佳答案

span {
    height: 259px;            
    display: table-cell;
    vertical-align: middle;
}

Demo

此外,more options用于垂直居中多行文本。

关于html - 垂直对齐图像旁边的文本,CSS 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14007253/

相关文章:

css - 带子菜单的 Z-Index

html - 悬停时从左上角移动到右下角

javascript - 为什么我在 div JavaScript 中得到额外的正斜杠

javascript - 如何使用 jQuery 缓慢地将 css 属性更改为自动?

php - DOMPDF - 背景 url(linux 与 windows)

html - 如何在 <h1> 中使用图像和重复背景

jquery - 调用后禁用 jQuery 函数

javascript - 我如何使用 tampermonkey href 本地文件?

jquery - 在弹出框中添加关闭按钮

html - 子菜单的子菜单不是内联的