Html 两个并排的div设置为display:table cell,但第二列中的文本正在下拉
我有一个布局,其中有一个包装器div和两个子divHtml 两个并排的div设置为display:table cell,但第二列中的文本正在下拉,html,css,internet-explorer-10,css-tables,Html,Css,Internet Explorer 10,Css Tables,我有一个布局,其中有一个包装器div和两个子div <!-- Display: table div --> <div class="about_us_row_content_wrapper boxsizing"> <!-- Table cell 1 with width 35% --> <div class="about_us_column about_us_imag
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
父div设置为display:table
,子div设置为display:table cell
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
我已将第一个表格单元格div设置为宽度:35%
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
它在Chrome中运行良好,但当它在IE10(或以下)中显示时,文本会显示在图像下方,或者显示时带有大量的填充
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
以下是表格的HTML:
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
我尝试添加垂直对齐:top“代码>添加到单元格内的所有文本,但这不起作用。”
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
我还尝试将width:50%
添加到两个单元格中,以查看这是否为文本提供了足够的上升空间,但事实并非如此
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
表格单元格元素上也没有minheight
,也没有填充,所以我不确定它是从哪里得到的
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
代码是实时的
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
在Chrome中工作正常:
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
在IE10中,它是否未按预期工作:
您需要为顶部设置垂直对齐:-将此设置应用于您右侧的所有列
<!-- Display: table div -->
<div class="about_us_row_content_wrapper boxsizing">
<!-- Table cell 1 with width 35% -->
<div class="about_us_column about_us_image">
<img src="<?php echo $link_path . 'images/aboutus/all_devices.png'; ?>" alt="Works on all devices, such as tablets, mobiles and desktops" />
</div>
<!-- Table cell 2 with assumed auto width, but text is dropping down-->
<div class="about_us_column">
<h3 class="opensans_thin about_us_section_header">Polls Everywhere, No compromises</h3>
<p class="about_us_section_paragraph">We worked hard so that you can make and take polls anywhere, anytime - no matter which device you're using.</p>
<p class="about_us_section_paragraph">Our fully featured poll maker works perfectly on phones, tablets and traditional desktops.</p>
</div>
</div>
.about_us_column{
vertical-align: top;
}
这里是@NoobEditor,这里是display:table
。:)@哈希姆·库拉米恐怕你的评论让我很吃惊:(在这个最新的问题中,…关于使用display:table
有很多争论,我明白了,我真的不想使用floats
。我使用了display:table
作为它的流体属性。我也发现使用它很容易对齐东西,但在这种情况下它不起作用了…很奇怪。有什么想法吗?请如果你认为这是一个有价值的问题,请回答。是的,这很有效,谢谢!我不知道为什么,我认为表格属性应该设置对齐方式?这类似于使td
textvertical align:top
垂直对齐,但是表格单元格应该自动向上推。我从未在实际的ce上设置过垂直对齐方式它通常会自动执行此操作?但超级智能浏览器IE会错过它:)