<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem 。这将有助于其他人回答问题。
关闭 4 年前。
标签 css css-tables
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem 。这将有助于其他人回答问题。
关闭 4 年前。
如何做到这一点?我想在我的表格中的行的顶部和底部边框上使用不同的颜色。如果我使用 display: block
,Chrome 会正确显示它,但我不知道这是否是正确的做法。但是,我希望它在 IE8 中工作,但我不知道如何。
我准备了一个可以在 Chrome 中运行的 fiddle :http://jsfiddle.net/s6LQ7/
最佳答案
这适用于 Firefox 和 IE8:
table {
width: 100%;
border-collapse: separate; /* Not really necessary unless you use normalize.js */
border-spacing: 0px; /* take out spaces between cells */
}
tr {
background-color: #ccc;
}
td {
width: 50%;
border-top: 1px solid #f00;
border-bottom: 1px solid #0f0; /* move spacing to the cell */
}
以上使用标准的 HTML 显示系统,因此它可以在 IE8 上运行。我有:
border-collapse
设置为separate
,这样可以防止表格折叠边框,因此它会绘制每个边框border-spacing
设置为 0px
以删除单元格之间的间距display
指令,允许表格显示为表格border
指令移至单元格,而不是行。 关于css - 表格行的顶部和底部边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14563567/
相关文章:
CSS Chrome 错误?显示水平滚动条 @ 100% 表格单元格
css - Internet Explorer 显示 : table issue
html - 在单个 div 中安装 3 个跨度,适用于 Chrome 但不适用于 Firefox
html - 如何使用 CSS 在一个 div 中使用多个 span 创建表格
javascript - bxslider 无法在 Bootstrap 3 选项卡中加载
html - 错误 CSS : vertical align in td with input text and image