css - 设置表格宽度 - 不受影响

标签 css class html-table

我正在尝试使用类选择器为某个表设置固定宽度。
但它根本不受影响。这种语法有什么遗漏/错误?

CSS

.delivoptions_table th {
  table-layout:fixed;
  overflow: hidden;
  width: 200px;
}

table ..
<div class = "delivoptions_table">
    <table id="deliver_alt_table">

            <tr>
                <td> ... </td>
            </tr>

         ...

    </table>
 </div>

最佳答案

您的 CSS 选择器针对所有 <th> .delivoptions_table 中的元素<div> ,但您没有任何 <th>里面的元素。更新您的选择器以定位 <table>本身:

.delivoptions_table table {
    table-layout:fixed;
    overflow: hidden;
    width: 200px;
}

关于css - 设置表格宽度 - 不受影响,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37540357/

相关文章:

python - 在 self 实现的对象/类的功能上使用 Pysparks rdd.parallelize().map()

javascript - JQuery Draggable with Touch Punch 停止垂直滚动

java - 使用 Java 打开和编辑 .jar 中的文件?

javascript - 防止单击和关闭覆盖菜单 css 时的主体滚动

c++ - 试图传入另一个类的枚举

php - 限制php中获取数据的列

jquery - 复制 html 表行并附加到其他表中

javascript - 单击时将单元格表更改为文本框

html - 将背景图像应用于图像元素

css - 位置 :fixed on element in ie7/8 and problems with the scrolling of the content inside it