就像 Gcyrillus 说的:
display: inline-block;
vertical-align: middle;
将工作。但是,您没有定义宽度。所以你要做的是:
.image{ width: 300px; padding-top:10px; padding-left:10px; padding-bottom:10px; }
.description{ width: 600px; font-size: 15px; font-style: italic; padding: 10px; color: #5C5C5C; text-shadow: 0px 0px 1px #A1A1A1; }
.image, .description{ display: inline-block; vertical-align: middle; }
一旦您将这些宽度更改为您需要的任何宽度,它就会对您很好。为了更好地衡量,请确保您不会成为 inline-block whitespace 错误的受害者,因此请应用:
.image { margin-left: -4px; } //It works sometimes for me but I think it isn't cross-browser very well.
或者不允许 HTML 中的元素之间有任何空格,如下所示:
<div class="description">
Lorem Ipsum
</div><div class="image">
<img />
</div>
另外,如果你想支持 IE7:
.image, .description { display: inline-block; vertical-align: middle; *display: inline; zoom: 1; } //Some people don't like the hacks and some people don't like supporting old IE ;-)