使用 Bootstrap,我试图将两个跨度(跨度 4 和 span8)中的文本和图像与同一跨度(span8)中的一个图像和文本垂直对齐。图像当前向左浮动。图像将根据浏览器窗口的宽度隐藏/取消隐藏,因此文本将占据隐藏图像的空间。那部分有效。
但是将文本与图像垂直对齐并没有,我已经查看并尝试了我能找到的每一个“解决方案”,但没有一个对我有用。文本的总高度小于图像的高度。
代码...
<div class="outer">
<div class="row">
<div class="span4">Line 1<br/>Line 2</div>
<div class="span8"><img src="http://lorempixel.com/90/90/abstract/" alt="" />This is a line of text. <br /> This is another line of text.<br /> This is a third line of text.</div>
</div>
</div>
.outer img {display:block;}
.outer .row {padding:4px; background-color:#CC9966}
.span4 {background-color:#555; width:100px; text-align:right}
.span8 {background-color:#777; width:400px}
.row img {float:left; padding-right:5px; width:90px; height:90px;}
/* styles from bootstrap */
.row {margin-left: 0px; *zoom: 1;}
.row:before,.row:after {display: table; content: ""; line-height: 0;}
.row:after {clear: both;}
[class*="span"] {float: left; min-height:1px; margin-left:12px;}
见http://jsfiddle.net/profweather/sN9rU/
我的项目中有二十四行,所以这种垂直对齐会重复很多次。
我最接近的是使用在http://phrogz.net/css/vertical-align/index.html上看到的相对和绝对定位的外部 div/内部 div但图像右侧的文本仍然对齐到图像的顶部,未垂直对齐到图像的 90 像素高度。
我什至尝试了表格布局,但无济于事。非常感谢任何帮助/指导。