简体   繁体   English

将左浮动div中的图像与右浮动div中的文本垂直对齐

[英]Vertical aligning an image in a left floated div with text on a right floated div

I'm having this problem where I have 2 divs on a content page (within a content wrapper) and I can't have the image aligned with the text next to it. 我遇到了一个问题,即我在内容页面上(内容包装器内)有2个div,并且图像无法与其旁边的文本对齐。

.text-block{position:relative; float:right; width:70%; height:auto}

then I have the image: 然后我有图像:

.img-block{position:relative; float:left; vertical-align:middle;}

Not sure if is possible to have an image aligned with text when they're in different divs though. 但是,当它们位于不同的div中时,不确定是否可以使图像与文本对齐。

Here I've made text vertical align as middle next to a image div. 在这里,我将文本垂直对齐到图像div的中间。 Only CSS, no JavaScript used. 仅CSS,不使用JavaScript。

Text Vertical Align Middle - Sample 文本垂直居中对齐-示例

Hope this is the result you expect... 希望这是您期望的结果...

If you are looking for some thing more, pls make comment... 如果您正在寻找更多东西,请发表评论...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM