简体   繁体   English

Internet Explorer 8忽略表上的colgroup宽度

[英]Internet Explorer 8 ignoring colgroup widths on table

For some odd reason IE is ignoring my column widths and just setting all six columns to equal widths. 出于某种奇怪的原因,IE忽略了我的列宽,只是将所有六列设置为相等的宽度。

table{
table-layout: fixed;
} 

<colgroup>
        <col style="width: 15%;" />
        <col style="width: 40%;"/>
        <col style="width: 5%;" />
        <col style="width: 10%;" />
        <col style="width: 10%;" />
        <col style="width: 20%;" />
    </colgroup>

Short answer: Because IE sucks 简短答案:因为IE很烂

Long answer: Use <table> , <tr> and <td> instead. 长答案:使用<table><tr><td>代替。 And use the colspan attribute to achieve the same effect. 并使用colspan属性达到相同的效果。

Sean you can use the <td> tag for styling your various widths, correct, but I don't see any issues with the code you are using now, provided the <colgroup> designation is placed in the proper placement relative to the <table> tag as follows: 肖恩,您可以使用<td>标记来设置各种宽度的样式,正确,但是如果<colgroup>名称相对于<table>放置在正确的位置,我现在看不到您使用的代码有任何问题。 <table>标签如下:

<table style="border:1px solid #000; table-layout:fixed;">
  <colgroup>
     <col style="width: 25%;" />
     <col style="width: 65%;" />
     <col style="width: 10%;" />
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
  <tr>
    <td>5869207</td>
    <td>My first CSS</td>
    <td>$49</td>
  </tr>
</table>

IE 8 apparently doesn't play nicely with jsfiddle, so I dumped the code into one of those W3C sandboxes to test. IE 8显然不能与jsfiddle很好地配合,所以我将代码转储到其中的W3C沙箱中进行测试。 Just go to that link in IE 8 and replace their colgroup section with what I have above, and hit the "submit code" button to view results. 只需转到IE 8中的链接,并用上面的内容替换其colgroup部分,然后单击“提交代码”按钮以查看结果。

Although you may already have come across this site and this note regarding IE8, those should be very helpful if you review them again in detail. 尽管您可能已经浏览过本网站和有关IE8的本说明 ,但是如果您再次详细阅读它们,它们将对您有所帮助。

IE8 is relatively incompatible web browser when it comes to parsing CSS. 在解析CSS时,IE8是相对不兼容的Web浏览器。

This limitation in IE8 becomes woefully salient when anyone tries to do sizing of any kind, be it windowing or table-sizing. 当任何人尝试进行任何大小调整(无论是窗口大小调整还是表大小调整)时,IE8中的此限制都将变得十分突出。

As indicated in one of the web-sites I mentioned above, you could try to complement IE8 with JavaScript instead of relying heavily on HTML and CSS only. 正如我在上面提到的一个网站中所指出的那样,您可以尝试用JavaScript补充IE8,而不是仅严重依赖HTML和CSS。

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

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