表格的边界半径不起作用 [英] Border Radius of Table is not working

查看:22
本文介绍了表格的边界半径不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在整个表格周围添加一个边框半径.但以下代码在最新版本的 Firefox 和 Google Chrome 中均无效.

I want to add a border radius around the entire table. But the following code is not working in both the latest versions of Firefox and Google Chrome.

<table class="bordered">
    <thead>
        <tr>
            <th><label>Labels</label></th>
            <th><label>Labels</label></th>
            <th><label>Labels</label></th>
            <th><label>Labels</label></th>
            <th><label>Labels</label></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><label>Value</label></td>
            <td><label>Value</label></td>
            <td><label>Value</label></td>
            <td><label>Value</label></td>
            <td><label>Value</label></td>                            
        </tr>
    </tbody>                    
</table>

CSS

table {
    border-spacing: 0;
    width: 600px;
    margin: 30px;
    border: 1px solid #CCCCCC;
    border-radius: 6px 6px 6px 6px;
    -moz-border-radius: 6px 6px 6px 6px;
    -webkit-border-radius: 6px 6px 6px 6px;
    box-shadow: 0 1px 1px #CCCCCC;
}        
table th:first-child {
    border-radius: 6px 0 0 0;
    -moz-border-radius: 6px 0 0 0;
    -webkit-border-radius: 6px 0 0 0;
}

table th:last-child {
    border-radius: 0 6px 0 0;
    -moz-border-radius: 0 6px 0 0;
    -webkit-border-radius: 0 6px 0 0;
}

table td:first-child, .bordered th:first-child {
    border-left: medium none;
}

table th {
    background-color: #DCE9F9;
    background-image: -moz-linear-gradient(center top , #F8F8F8, #ECECEC);
    background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(#F8F8F8), to(#ECECEC), color-stop(.4, #F8F8F8));
    border-top: medium none;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

table td, table th {
    border-left: 1px solid #CCCCCC;
    border-top: 1px solid #CCCCCC;
    padding: 10px;
    text-align: left;
}

jsFiddle

推荐答案

它可以工作,这是使用的工具的问题:jsFiddle 的 normalized CSS 通过隐藏默认的浏览器...
http://jsfiddle.net/XvdX9/5/

It works, this is a problem with the tool used: normalized CSS by jsFiddle is causing the problem by hiding you the default of browsers...
See http://jsfiddle.net/XvdX9/5/


normalize.css 来自 jsFiddle 的样式表将指令 border-collapse: collapse 添加到所有表格它在 CSS2.1 中以完全不同的方式呈现它们:


normalize.css stylesheet from jsFiddle adds the instruction border-collapse: collapse to all tables and it renders them completely differently in CSS2.1:

这两个模型之间的差异可以在另一个小提琴中看到:http://jsfiddle.net/XvdX9/11/(在单元格上有一些透明度,左上角有一个巨大的边界半径,以便查看表格与其单元格上发生的情况)

Differences between the 2 models can be seen in this other fiddle: http://jsfiddle.net/XvdX9/11/ (with some transparencies on cells and an enormous border-radius on the top-left one, in order to see what happens on table vs its cells)

在关于HTML表格的同一个CSS2.1页面中,也有关于浏览器应该/可以对分离边框模型中的空单元格做什么的解释,border-style:none的区别和 border-style: hidden 在折叠边框模型中,如果表格、行和单元格元素在同一边框上定义了 3 种不同的样式,则如何计算宽度以及应显示哪个边框.

In the same CSS2.1 page about HTML tables, there are also explanations about what browsers should/could do with empty-cells in the separated borders model, the difference between border-style: none and border-style: hidden in the collapsing borders model, how width is calculated and which border should display if both table, row and cell elements define 3 different styles on the same border.

这篇关于表格的边界半径不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆