html - 表格布局 :fixed is not working IE7

标签 html css

我正在使用一个包含多行的表格。只有几行有不止一列。我已经将表格的宽度设置为 980px。但是第一列占980px,第2列超出980px。我使用了表格布局:固定的。它不工作 IE7。

<!DOCTYPE html>
<html>
 <head>
  <style>
   table{
        table-layout:fixed;
        *table-layout:fixed;
        width:960px;
        min-width:50px
        }
    td{
        border:1px solid black;
      }
 </style>
 </head>
 <body>
 <table>
 <tr>  <td>SomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeText</td></tr>
 <tr><td> SomeTextSomeTextSomeTextSomeTextSomeText</td>
 <td> SomeTextSomeText</td></tr>
 <tr><td>SomeTextSomeText</td> </tr>
 </table>
 </body>
 </html>

我通常使用 hack 来修复 IE,比如 *table-layout:fixed。它适用于 IE8+,但不适用于 IE7。

最佳答案

我得到了答案: Colspan 或 colgroup 可用于根据我们的喜好更改列宽。

<!DOCTYPE html>
<html>
<head>
<style>
 table{
    table-layout:fixed;
    *table-layout:fixed;
    width:960px;
    min-width:50px
    }
td{
    border:1px solid black;
  }
 </style>
 </head>
 <body>
  <table>
  <tr>  <td colspan ="2">SomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeText</td>     </tr>
 <tr><td colspan="1"> SomeTextSomeTextSomeTextSomeTextSomeText</td>
  <td> SomeTextSomeText</td>.    </tr>
  <tr><td>SomeTextSomeText</td>    </tr>
  </table>
  </body>
  </html>

关于html - 表格布局 :fixed is not working IE7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29326251/

相关文章:

html - 限制空间文本可以占用一个 div

html - 如何计算移动设备上 Bootstrap 列的宽度?

css - Bootstrap 4.0 自定义汉堡图标

javascript - 将类添加到 html 表格的特定单元格

javascript - react : How to prompt for unsaved changes when navigating with react-router-component

javascript - jQuery,如何选择动态生成的html元素

css - 更改angular2中伪元素的样式

css - "Eliminate render-blocking CSS in above-the-fold content"

javascript - 如何在 jquery transit 中暂停和重新启动 css3 转换

javascript - 当在同一个窗口中打开 url 时,window.opener 未定义