0

我有一张桌子,希望在 TD 的宽度上拉伸某个背景,无论宽度是多少。

我的相关CSStd目前是这样的:

.tools .theader
{
margin:1px;background-color:#ffffcc;
background:url(../images/td_bg.png) no-repeat center center;
}

HTML 是这样的:

<table class'tools'>
<tr>
<td class='theader' colspan=2>
Background
</td>
...

这是我得到的结果的图像: 在此处输入图像描述

所以你可以看到蓝色斜角背景正好适合每个td. 我希望它伸展到边缘,td使整体td看起来倾斜。如何才能做到这一点?

4

1 回答 1

1

您可以改用css渐变

HTML

<table class'tools'>
<tr>
<td class='theader' colspan="2">
    <span>Background</span>
</td>
    </tr>
    </table>

CSS

.theader > span{
    color:white;
    padding:6px 10px;
    background: #fffcfc; /* Old browsers */
background: -moz-linear-gradient(top,  #fffcfc 0%, #2989d8 12%, #2989d8 51%, #207cca 96%, #ffffff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fffcfc), color-stop(12%,#2989d8), color-stop(51%,#2989d8), color-stop(96%,#207cca), color-stop(100%,#ffffff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #fffcfc 0%,#2989d8 12%,#2989d8 51%,#207cca 96%,#ffffff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #fffcfc 0%,#2989d8 12%,#2989d8 51%,#207cca 96%,#ffffff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #fffcfc 0%,#2989d8 12%,#2989d8 51%,#207cca 96%,#ffffff 100%); /* IE10+ */
background: linear-gradient(to bottom,  #fffcfc 0%,#2989d8 12%,#2989d8 51%,#207cca 96%,#ffffff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fffcfc', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */

}

演示

这里是生成 CSS Gradient 的最佳工具

于 2013-03-14T07:27:54.963 回答