html - TD背景有两种颜色

标签 html css

<分区>


关闭 6 年前

这里有一个简短的问题,css3 gradient 对我的要求没有帮助。我需要用两种颜色突出显示 td,左半部分用一种颜色,右半部分用另一种颜色。

输出应该是:

enter image description here

我怎样才能做到这一点?

最佳答案

你需要这样吗? 不知道对不对?

<!DOCTYPE html>
<html>
    <head>
        <style>
            table td {
                border: 1px solid black;
                background: linear-gradient( to right, #ff9e2c 0%, #ff9e2c 50%, #FF0000 50%, #FF0000 100%);
            }
        </style>
    </head>
    <body>
        <table>
            <tr>
                <th>Month</th>
                <th>Savings</th>
            </tr>
            <tr>
                <td>January</td>
                <td>$100</td>
            </tr>
            <tr>
                <td>Feb</td>
                <td>$1000</td>
            </tr>
            <tr>
                <td>March</td>
                <td>$10</td>
            </tr>
            <tr>
                <td>April</td>
                <td>$110</td>
            </tr>
        </table>
    </body>
</html>

关于html - TD背景有两种颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37782972/

上一篇:html - a :hover in span tag, 如何去除悬停样式

下一篇:jquery - Bootstrap 响应式网格不起作用

相关文章:

JavaScript 链接 VS CSS 链接

php - 关于我的 Google Recaptcha 代码

html - 如何为 CSS 排列等宽字体的英文和中文字符?

html - 在 Nokogiri 中选择变体

html - 如果我使用以下代码,为什么我的圆 Angular 在 IE 中不起作用

css - 高性能的 CSS3 动画(简单的动画在 Chrome 开发者工具中仍然没有表现)

html - 使用超大图像作为标题——如何在水平调整大小时保持图像居中

html - 通过 CSS 访问 html 内容?

html - SVG 元素无法在 Safari 中显示阴影过滤器

php - 如何正确链接 CSS 文件与 PHP 页脚和页眉