简体   繁体   English

左右替代组中的浮动图像和文本在div的未知高度中垂直对齐中间

[英]Floated image in left and right alternative group and text vertically align middle in an unknown height of div

Is it possible to make the text vertically align middle in an unknown height of div with a floated image. 是否有可能使文本垂直浮动在div未知高度的中间并与浮动图像对齐。 The first and third div group of 'groupsection2', image will float to left; “ groupsection2”的第一个和第三个div组,图像将向左浮动; and the second and forth group of 'groupsection2', image float to right: 第二组“ groupsection2”,图像向右浮动:

<div class="groupsection2 clear">
<div class="groupfeature">
<span><img src="testing-images/antec-quality-h230.png" alt="" height="230"/></span>
<div class="feature-content">
<h3>Reliability you can count on Reliability you can count on</h3>
<p>EA-380D Green is backed with AQ3 - Antec Quality 3 year parts and labor warranty, and you get   
unlimited access to Antec’s incomparable technical support and customer service</p>
</div>
</div>

<div class="groupsection2 clear">
<div class="groupfeature">
<span><img src="testing-images/antec-quality-h230.png" alt="" height="230"/></span>
<div class="feature-content">
<h3>Reliability you can count on Reliability you can count on</h3>
<p>EA-380D Green is backed with AQ3 - Antec Quality 3 year parts and labor warranty, and you get   
unlimited access to Antec’s incomparable technical support and customer service</p>
</div>
</div>

<div class="groupsection2 clear">
<div class="groupfeature">
<span><img src="testing-images/antec-quality-h230.png" alt="" height="230"/></span>
<div class="feature-content">
<h3>Reliability you can count on Reliability you can count on</h3>
<p>EA-380D Green is backed with AQ3 - Antec Quality 3 year parts and labor warranty, and you get   
unlimited access to Antec’s incomparable technical support and customer service</p>
</div>
</div>

You haven't shared any of your CSS code. 您尚未共享任何CSS代码。 You also seems to be missing a closing </div> tag in each code block. 您似乎还缺少每个代码块中的</div>标记。

Here's a suggestion to achieve what I think you're trying to do (works on IE9+): 这是实现我认为您要尝试完成的建议(适用于IE9 +):

HTML HTML

<div class="groupsection2 clear">
<div class="groupfeature">
<span><img src="testing-images/antec-quality-h230.png" alt="" height="230"/></span>
<div class="feature-content">
<h3>Reliability you can count on Reliability you can count on</h3>
<p>EA-380D Green is backed with AQ3 - Antec Quality 3 year parts and labor warranty, and you get   
unlimited access to Antec’s incomparable technical support and customer service</p>
</div>
</div>
</div>

<div class="groupsection2 clear">
<div class="groupfeature">
<span><img src="testing-images/antec-quality-h230.png" alt="" height="230"/></span>
<div class="feature-content">
<h3>Reliability you can count on Reliability you can count on</h3>
<p>EA-380D Green is backed with AQ3 - Antec Quality 3 year parts and labor warranty, and you get   
unlimited access to Antec’s incomparable technical support and customer service</p>
</div>
</div>
</div>

<div class="groupsection2 clear">
<div class="groupfeature">
<span><img src="testing-images/antec-quality-h230.png" alt="" height="230"/></span>
<div class="feature-content">
<h3>Reliability you can count on Reliability you can count on</h3>
<p>EA-380D Green is backed with AQ3 - Antec Quality 3 year parts and labor warranty, and you get   
unlimited access to Antec’s incomparable technical support and customer service</p>
</div>
</div>
</div>

CSS CSS

.feature-content {
    position: relative;
    top: 50%;
    transform: translateY(50%);
}

Fiddle 小提琴
http://jsfiddle.net/tmabpn8d/ http://jsfiddle.net/tmabpn8d/

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

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