小编VIK*_*MAR的帖子

背景颜色CSS属性在表中不起作用

这是 html 和 CSS 代码:

    table,th,td{
      border:1px solid blue;
      border-collapse:collapse;
    }
    td{
      text-align:center;
    }
    td{padding:10px;
      color:#cc7722;
    }
    table{
      border-spacing:5px;
      background-color:yellowgreen;
      font-weight:bold;
      width:100%
    }
    #hello{
      color:red;
    }
    .hi{
      background-color:blue;
    }
Run Code Online (Sandbox Code Playgroud)
     <table>
          <caption id="hello">Employee Data</caption>
          <tr>
            <div class="hi">
            <th>Employee Name</th>
            <th>
              Department
            </th>
            <th>Salary</th>
            </div>
          </tr>
          <tr>
            <td>Vaibhav</td>
            <td>CSE</td>
            <td>10000</td>
          </tr>
        </table>
Run Code Online (Sandbox Code Playgroud)

输出

这里未显示 hi 类的背景色蓝色 ,那么原因是什么以及可能的解决方案是什么

html css web

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

css ×1

html ×1

web ×1