填充表与css不工作在IE [英] padding table with css doesn't work on IE

查看:91
本文介绍了填充表与css不工作在IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这对我的IE无效:

 < table style =padding:5px> ... < / table> 



但是它适用于Opera。



有解决方法吗?感谢

解决方案

早期的CSS规范(IE6遵循 - 我使用以下一词松散)在表上定义的填充应该意味着什么。 IE6,自然,决定解释这不同于每一个其他浏览器,通过忽略填充。其他浏览器决定通过在表边框和最外面的单元格之间添加间距来渲染它,而不会影响单元格内​​部或内部单元格之间的间距。到IE7的时候,规格已经清除了工作像其他浏览器,但IE6仍然有问题,它只是忽略了填充。



最好的解决方案是避免在表上填充padding,而是用一个div包围它,然后把padding放在那里。

  div style =padding:5px;> 
< table ...>
< / table>
< / div>

当然,如果你想要的是单元格间距或单元格填充表),那么你应该使用 cellspacing cellpadding 属性(即使你不想要这些,最少需要 cellspacing =0,以避免与IE6表呈现有关的另一个单独问题)。



样式这里是为演示目的;使用css类通常被认为是更好的做法。


This is not working on my IE:

<table style="padding:5px">...</table>

however it works on Opera.

Is there a workaround? thanks

解决方案

The earlier CSS specs (which IE6 follows -- and I use the word "follows" loosely) are not clear about what padding defined on a table should even mean. IE6, naturally, decided to interpret this differently than every other browser, by ignoring the padding. Other browsers decided to render it by adding spacing between the table border and the outermost cells, without affecting the spacing inside cells, or between internal cells. By the time IE7 came out, the specs had cleared up to work like the other browsers, but IE6 still has the problem, where it simply ignores the padding.

The best solution is to avoid putting padding on your table, but instead surrounding it with a div, and putting the padding there.

<div style="padding: 5px;">
    <table...>
    </table>
</div>

Of course, if what you want is cell spacing or cell padding (as opposed to just padding on the table), then you should use the cellspacing or cellpadding attributes (even if you don't want these, you at least need cellspacing="0" to avoid another separate issue with IE6 table rendering).

Also, the inline styles here are for demo purposes; using css classes is generally considered better practice.

这篇关于填充表与css不工作在IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆