javascript - 表列错位

标签 javascript jquery html asp.net css

请考虑以下 ( http://jsfiddle.net/HaLGr/11/ ):

.head_row {
    color: #FFFFFF;
    background-color: #5D7B9D;
}
.row_one {
    font-size: 12px;
}
.row_two {
    font-size: 12px;
    display: none;
}
.row_three {
    font-size: 12px;
    display: block;
}


<table name="main_table" id="main_tbl">
    <tr>
        <td class="head_row">Column 1</td>
        <td class="head_row">Column 2</td>
    </tr>
    <tr class="row_one">
        <td>Row One</td>
        <td>Row One</td>
    </tr>
    <tr class="row_two">
        <td>Row Two</td>
        <td>Row Two</td>
    </tr>
    <tr class="row_three">
        <td>Row Three</td>
        <td>Row Three</td>
    </tr>
</table>

为什么在使用 display: block 时第三行的单元格未对齐?

enter image description here

我需要能够隐藏(display: none)和显示(display: block)具有正确列对齐的表格行。

最佳答案

默认情况下,行具有由浏览器样式表设置的display: table-row;。显然它与 display: block 完全不同。

您应该在 CSS 中做的是:

.row_three {
    font-size: 12px;
    display: table-row;
}

关于javascript - 表列错位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16945833/

相关文章:

javascript - 圆滑的轮播错误 : null is not an object (evaluating 'b.$slides.add' )

javascript - 交互式弹线Canvas框架?

javascript - AngularJS $uibModal 不工作

javascript - 值得先检查一个元素是否存在?

JavaScript:textarea 滚动了多少?

javascript - 为什么当我单击下一个或上一个时,完整日历 jquery 插件无法按预期工作?

javascript - 如何在没有额外键的情况下循环创建数组对象?

jQuery 从属性值检索数组

javascript - onclick 在 Internet Explorer 7 中不起作用

html - 如何让表格重叠图像?