Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 不仅在文本上设置背景色,而且在td中设置空白_Css - Fatal编程技术网

Css 不仅在文本上设置背景色,而且在td中设置空白

Css 不仅在文本上设置背景色,而且在td中设置空白,css,Css,我想使用span将背景色设置为孔td 这是我的密码: <td> <span style="background-color: red;">pending</span> </td> 悬而未决的 如果我给它这样,我得到的背景颜色的文字只,但我想bg颜色洞td <td style="background-color: red;"> <span>pending</span> </td> 悬而

我想使用span将背景色设置为孔td

这是我的密码:

<td>
<span style="background-color: red;">pending</span>
</td>  

悬而未决的
如果我给它这样,我得到的背景颜色的文字只,但我想bg颜色洞td


<td style="background-color: red;">
<span>pending</span>
</td>  
悬而未决的
设置单元格本身的背景色,而不是span

尝试以下操作:

    <td>
        <span style="background-color: red;width:100%;height:100%;display:block;">pending</span>
    </td> 

悬而未决的

请参见试试这个:

<table width="100%">
   <tr>
      <td>
    <span style="background-color: red; display:block;">
           pending
        </span>
      </td> 
   </tr>    
</table>

悬而未决的

Hi ubercooluk,,我不想在td中使用样式。。因此,使用span应该设置bg颜色。任何其他替代设置或为您的td设置一个类,比如说
.foo
,并在ur cssok中添加样式,因此将span宽度和高度设置为100%,以填充父级(在本例中为td)。您可以在您的帖子中添加更多html代码和css样式吗?因为我的代码有效(你可以在“示例”链接上看到)