Html 如何在td中有两种背景色而不跨越它?

Html 如何在td中有两种背景色而不跨越它?,html,Html,您好,先生/女士,我想在td的顶部和底部使用不同的背景,即前半部分应为绿色,后半部分为红色…尝试渐变: td { background: #00ff00; background: -moz-linear-gradient(top, #00ff00 0%, #00ff00 49%, #ff0000 50%, #ff0000 100%); background: -webkit-gradient(linear, left top, left bottom, color-st

您好,先生/女士,我想在td的顶部和底部使用不同的背景,即前半部分应为绿色,后半部分为红色…

尝试渐变:

td {
    background: #00ff00;
    background: -moz-linear-gradient(top,  #00ff00 0%, #00ff00 49%, #ff0000 50%, #ff0000 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00ff00), color-stop(49%,#00ff00), color-stop(50%,#ff0000), color-stop(100%,#ff0000));
    background: -webkit-linear-gradient(top,  #00ff00 0%,#00ff00 49%,#ff0000 50%,#ff0000 100%);
    background: -o-linear-gradient(top,  #00ff00 0%,#00ff00 49%,#ff0000 50%,#ff0000 100%);
    background: -ms-linear-gradient(top,  #00ff00 0%,#00ff00 49%,#ff0000 50%,#ff0000 100%);
    background: linear-gradient(to bottom,  #00ff00 0%,#00ff00 49%,#ff0000 50%,#ff0000 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ff00', endColorstr='#ff0000',GradientType=0 );
}

要编辑此渐变,请使用。

使用CSS渐变。在您的情况下,CSS将是:

background-image: linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -o-linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -moz-linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -webkit-linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -ms-linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);

background-image: -webkit-gradient(
    linear,
    left bottom,
    left top,
    color-stop(0.5, rgb(0,255,0)),
    color-stop(0.5, rgb(255,0,0))
);

使用此网站生成更多信息:

要直接执行此操作,可以将此功能设置为背景图像。 差不多

style="background-image:url(twocolor.png);"

如果你不喜欢渐变(只是为了好玩)

你试过使用渐变吗?看看这个:我不会试的Mark Dee先生我检查了你的链接Ophintor先生但它是为了改变奇偶起伏的背景,只需使用一个图像,然后谢谢你Mark Dee先生,现在我得到了我的输出