2012-04-08 133 views
0

我基本上试图创建一个液体<h1>和另一个div将跨越整个高度<h1>,但我希望垂直对齐居中。我基本上试图把一个图像放在页面标题的左侧:CSS垂直对齐的图像/文字

<div class="outer"> 
    <div><img src="pound.png" /></div> 
    <h1>This is text that is really long. This is text that is really long. This is text that is really long. This is text that is really long. This is text that is really long.</h1> 
</div> 

这里是一个例子;我真的不想使用表格,因为我希望能够在某些情况下将图像浮动到右侧。我也不在乎边界,我只是在做它来说明这种对齐。

------------------------------------------------------ 
     | This is text that is really long. This is 
###### | text that is really long. This is text that 
###### | is really long. This is text that is really 
###### | long. This is text that is really long. This 
     | is text that is really long. 
------------------------------------------------------ 

我的主要问题是如何将图像垂直占据了整个空间,这样我可以用保证金垂直对齐:50%以上的汽车或一些变化。我可以让图像垂直居中,但是文字环绕它,或者我可以让文字不包裹,但是图像垂直对齐。

回答

0

浏览器支持目前有点受限,但您可以尝试使用box-align css属性来垂直对齐图片和文本。更多here

-1

尝试使用行高。此外,如果可能的话,会更容易使用DIFFS

+0

我该怎么做2 div? – Mark 2012-04-09 01:16:08

+0

将两个div放入容器中。一个与图像另一个文本: – Ray 2012-04-09 03:27:21