显示:表格单元格;在 ie6/7 中解决方法

发布于 2024-09-19 18:18:52 字数 881 浏览 1 评论 0原文

我正在尝试构建一个包含多个单元格的单行 css 表,其中的文本在单元格内垂直居中。基本上我试图用 css 模仿的表格行为是这样的:

<table width="100%" height="54" border="0" bgcolor="red">
 <tr>
    <td width="20%">text</td>
    <td width="20%">text</td>
    <td width="20%">text</td>
    <td width="20%">text</td>
    <td width="20%">text</td>
  </tr>
</table>

为了使我的代码在语义上是正确的,我想使用 div 来达到相同的效果。

<div class="job_wrapper">
 <div class="info">
  <div>01</div>
  <div>Campaign 001</div>
  <div>DEMO Client</div>
  <div>128</div>
  <div>449</div> 
 </div>
</div>

问题是 IE 中的 display:table-cell 的解决方法涉及使用 float 属性来覆盖要阻止的显示值。因此我失去了表格单元格中文本的垂直居中。

是否有一种解决方法可以在 IE 中显示:表格单元格,仍然使我能够在 IE 中垂直居中文本?

干杯

I'm trying to build a single row css table with multiple cells that has text that is vertically centered inside the cells. Basically the table behaviour I am trying to mimic with css is this:

<table width="100%" height="54" border="0" bgcolor="red">
 <tr>
    <td width="20%">text</td>
    <td width="20%">text</td>
    <td width="20%">text</td>
    <td width="20%">text</td>
    <td width="20%">text</td>
  </tr>
</table>

So that my code is semantically correct I want to use divs to achieve the same effect.

<div class="job_wrapper">
 <div class="info">
  <div>01</div>
  <div>Campaign 001</div>
  <div>DEMO Client</div>
  <div>128</div>
  <div>449</div> 
 </div>
</div>

Problem is that the workaround for display:table-cell in IE involved using the float property which overrides the display value to block. hence I lose the vertical centering of text in a table cell.

Is there a workaround to display:table-cell in IE that still gives me the ability to center text vertically in IE?

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜访吸血鬼 2024-09-26 18:18:52

查看 http://jogger.pl/404 中的样式表。

他们有一个有趣的解决方法。

check out the style sheet from http://jogger.pl/404.

they have an interesting workaround in there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文