html - 同时在表格的标题上获取边框半径和渐变时遇到问题

标签 html css google-chrome firefox

更新:现在它可以在 Chrome 而不是 Firefox 中运行

我无法同时在表格的标题上获取边框半径和渐变。

//normal table
<table cellspacing="0">
    <thead>
        <tr class ="header">
        <th>one</th><th>two</th><th>three</th><th>four</th>
        </tr>
    </thead>
    <tr><td>onetd</td><td>twotd</td><td>threetd</td><td>fourtd</td></tr>
    <tr><td>onetd</td><td>twotd</td><td>threetd</td><td>fourtd</td></tr>
    <tr><td>onetd</td><td>twotd</td><td>threetd</td><td>fourtd</td></tr>
</table>

CSS 无效。梯度取自一些梯度生成器

    tr:nth-child(even){
        background-color: yellow;
    }
        tr:nth-child(odd){
        background-color: green;
    }
    table thead tr.header{
            border-top-left-radius: 30px;
    border:1px solid black;
         background-image: linear-gradient(bottom, rgb(52,156,235) 19%, rgb(61,224,216) 60%);
        background-image: -o-linear-gradient(bottom, rgb(52,156,235) 19%, rgb(61,224,216) 60%);
        background-image: -moz-linear-gradient(bottom, rgb(52,156,235) 19%, rgb(61,224,216) 60%);
        background-image: -webkit-linear-gradient(bottom, rgb(52,156,235) 19%, rgb(61,224,216) 60%);
        background-image: -ms-linear-gradient(bottom, rgb(52,156,235) 19%, rgb(61,224,216) 60%);

        background-image: -webkit-gradient(
          linear,
          left bottom,
          left top,
          color-stop(0.19, rgb(52,156,235)),
          color-stop(0.6, rgb(61,224,216))
        );
    }


table thead tr.header > th:nth-child(1){
border-top-left-radius:10px; 


}

我绝对希望它能在主流浏览器中运行

不工作 jsfiddle

最佳答案

CSS:

.border{
            border: 2px solid #666666;
            border-radius: 5px 5px 0px 0px;
            -moz-border-radius: 5px 5px 0px 0px;
            -webkit-border-radius: 5px 5px 0px 0px;
        }
        table {
            margin: 50px;
            border-spacing: 0;
            width: 450px;
        }        
        .border th:first-child {
            border-radius: 5px 0 0 0;
            -moz-border-radius: 5px 0 0 0;
            -webkit-border-radius: 5px 0 0 0;
        }

        .border th:last-child {
            border-radius: 0 5px 0 0;
            -moz-border-radius: 0 5px 0 0;
            -webkit-border-radius: 0 5px 0 0;
        }

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

        .border th {
            background-color: #666666;
            background-image: -moz-linear-gradient(center top , #3DE0D8, #349CEB);
            background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(#3DE0D8), to(#349CEB), color-stop(.4, #3DE0D8));
        }

        .border td, .border th {
            border-left: 2px solid #666666;
            border-top: 2px solid #666666;
            padding: 10px;
            text-align: center;
        }

        tr:nth-child(even){
            background-color: yellow;
        }
        tr:nth-child(odd){
            background-color: green;
        }

html:

<table class="border">
        <thead>
            <tr>
                <th><label>one</label></th>
                <th><label>two</label></th>
                <th><label>Three</label></th>
                <th><label>Four</label></th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><label>one</label></td>
                <td><label>two</label></td>
                <td><label>Three</label></td>
                <td><label>Four</label></td>
            </tr>
            <tr>
                <td><label>one</label></td>
                <td><label>two</label></td>
                <td><label>Three</label></td>
                <td><label>Four</label></td>
            </tr>
            <tr>
                <td><label>one</label></td>
                <td><label>two</label></td>
                <td><label>Three</label></td>
                <td><label>Four</label></td>
            </tr>
        </tbody>                    
    </table>

关于html - 同时在表格的标题上获取边框半径和渐变时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19650348/

相关文章:

html - 赋予不同的细胞颜色

javascript - 具有无限水平滚动的可调整大小的流体图像(修订版 2)

html - CSS - 子元素的边框覆盖父元素

jquery - html div滚动条错误

javascript - console.timeEnd ("start")不工作

javascript - 获取用于绘制的图像比 getElementById 更好的方法吗?

html - 溢出自动不适用于 flex 容器

javascript - 目录卡片。悬停时翻转,当用户发现时取消翻转

javascript - 奇怪的 : CSS transformated element JS "click through"

css - @page :first { margin: . .. } 在 Chrome 错误中?