为特定的表[row][col]应用透明背景色


Apply a transparent background color to a particular table[row][col]

我希望table的特定单元格的背景颜色为浅黄色(即透明黄色),为此我使用了属性'rgba'

我甚至删除了整个分区的背景,以保持颜色的透明度。但是它只显示黑色作为背景。

<div id="top">
	<table height="60px" width="1030px">
	<tr> 
		<th bgcolor="rgba(222,215,11,0.3)"><u><a href="forum.php" class="class2">Forum</a></u></th>
		<th><u><a href="quest.php"class="class2">My Questions</a></u></th>
		<th><u><a href="answerswers.php"class="class2">My Answers</a></u></th>
	</tr>
	</table> 
</div>

使用合适的css样式:background-color

<div id="top">
<table height="60px" width="1030px">
<tr> 
<th style="background-color: rgba(222,215,11,0.3)"><u><a href="forum.php" class="class2">Forum</a></u></th>
<th><u><a href="quest.php"class="class2">My Questions</a></u></th>
<th><u><a href="answerswers.php"class="class2">My Answers</a></u></th>
</tr>
</table> 
</div>

<body bgcolor="color_name|hex_number|rgb_number">

HTML5不支持bgcolor属性。

见此处bgcolor

但是你应该使用background-color 属性

background-color: color|transparent|initial|inherit;

可以写在CSS th { background-color:rgba(222,215,11,0.3) }

或内联CSS <th style="background-color:rgba(222,215,11,0.3)"></th>

background-color

我也建议你不要使用<u>标签,特别是在默认带下划线的<a>标签上。

元素在HTML 4.01中已弃用。(该元素用于定义带下划线的文本)。

元素在HTML5中被重新定义,以表示应该在风格上不同于正常文本的文本,例如拼写错误的单词或中文专有名词。

bgcolor的情况下,我建议你使用CSS或内联CSS使用text-decoration:underline而不是<u>

点击这里阅读更多HTML <你的在标记>

为您的答案。请参阅下面的代码片段。欢呼;)

<div id="top">
<table height="60px" width="1030px">
<tr> 
<th style="background-color:rgba(222,215,11,0.3)"><a href="forum.php" class="class2">Forum</a></th>
<th><a href="quest.php"class="class2">My Questions</a></th>
<th><a href="answerswers.php"class="class2">My Answers</a></th>
</tr>
</table> 
</div>

BGColor在W3C HTML 4.0规范中已弃用。另外,bgcolor不能与rgba的值一起工作。

使用background-color的CSS样式代替bgcolor

<div id="top">
<table height="60px" width="1030px">
<tr> 
<th style="background-color: rgba(222,215,11,0.3)"><u><a href="forum.php" class="class2">Forum</a></u></th>
<th><u><a href="quest.php"class="class2">My Questions</a></u></th>
<th><u><a href="answerswers.php"class="class2">My Answers</a></u></th>
</tr>
</table> 
</div>

可以用style代替bgcolor

<div id="top">
	<table height="60px" width="1030px">
		<tr> 
			<th style="background:rgba(222,215,11,0.3)"><u><a href="forum.php" class="class2">Forum</a></u></th>
			<th><u><a href="quest.php"class="class2">My Questions</a></u></th>
			<th><u><a href="answerswers.php"class="class2">My Answers</a></u></th>
		</tr>
	</table> 
</div>

你应该使用# color编码。

你能试一下吗?

<div id="top">
 <table height="60px" width="1030px">
   <tr> 
    <th bgcolor="#FFFFE0"><u><a href="forum.php" class="class2">Forum</a></u></th>
    <th><u><a href="quest.php"class="class2">My Questions</a></u></th>
    <th><u><a href="answerswers.php"class="class2">My Answers</a></u></th>
   </tr>
  </table> 
</div>

你应该试试inline css。

<div id="top">
    <table height="60px" width="1030px">
        <tr> 
            <th style="background-color: #ffff99 "><u><a href="forum.php" class="class2">Forum</a></u></th>
            <th><u><a href="quest.php"class="class2">My Questions</a></u></th>
            <th><u><a href="answerswers.php"class="class2">My Answers</a></u></th>
        </tr>
    </table> 
</div>