【问题标题】:Apply a transparent background color to a particular table[row][col]将透明背景颜色应用到特定表格[row][col]
【发布时间】:2016-08-10 12:56:35
【问题描述】:

我希望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="answers.php"class="class2">My Answers</a></u></th>
	</tr>
	</table> 
</div>

【问题讨论】:

  • 在下面添加了完整的解释。我猜你已经很久没有用 HTML 编写了,或者你没有使用 HTML 5 :) 不用担心,很容易习惯“新”功能

标签: php html css html-table


【解决方案1】:

使用适当的 css 样式:背景颜色

<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="answers.php"class="class2">My Answers</a></u></th>
</tr>
</table> 
</div>

【讨论】:

    【解决方案2】:

    &lt;body bgcolor="color_name|hex_number|rgb_number"&gt;

    HTML5 不支持 bgcolor 属性。改用 CSS。

    看这里bgcolor

    但您应该使用 background-color 属性

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

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

    或内联 CSS &lt;th style="background-color:rgba(222,215,11,0.3)"&gt;&lt;/th&gt;

    更多信息在这里background-color

    我还建议您不要使用&lt;u&gt; 标签,尤其是在默认带下划线的&lt;a&gt; 标签上。

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

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

    就像bgcolor的情况一样,我建议你使用CSS或使用text-decoration:underline而不是&lt;u&gt;的内联CSS

    在此处阅读更多信息HTML < u > Tag

    为您解答。请参见下面的 sn-p。干杯;)

    <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="answers.php"class="class2">My Answers</a></th>
    </tr>
    </table> 
    </div>

    【讨论】:

    • 很高兴我能帮上忙 :) 不要忘记将我的回答评为已接受。因此,如果其他人在这件事上需要帮助,请查看答案。谢谢 ! :D
    【解决方案3】:

    BGColor 在 W3C HTML 4.0 规范中已弃用。此外,bgcolor 不适用于 rgba 值。

    使用 CSS 样式 background-color 而不是 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="answers.php"class="class2">My Answers</a></u></th>
    </tr>
    </table> 
    </div>

    【讨论】:

      【解决方案4】:

      您可以使用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="answers.php"class="class2">My Answers</a></u></th>
      		</tr>
      	</table> 
      </div>

      【讨论】:

        【解决方案5】:

        你应该使用#颜色编码。

        你可以试试下面吗。

        <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="answers.php"class="class2">My Answers</a></u></th>
           </tr>
          </table> 
        </div>

        【讨论】:

          【解决方案6】:

          你应该试试内联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="answers.php"class="class2">My Answers</a></u></th>
                  </tr>
              </table> 
          </div>
          

          【讨论】:

            猜你喜欢
            • 2022-01-09
            • 2012-11-05
            • 2012-06-26
            • 1970-01-01
            • 1970-01-01
            • 2011-07-06
            • 1970-01-01
            • 2014-03-22
            • 2019-09-29
            相关资源
            最近更新 更多