html - 如何在html中设置表头和表数据

标签 html css

我无法将表格设置为与标题相同。请帮助并提前致谢。 代码和图片如下。 enter image description here

    <!-- This is the table Style-->
    <style>
        table {
            width:100%;
        }
        th, td {
            width: 100%;
            border: 3px solid black;
            border-collapse: collapse;
        }
        th, td {
            width: 100%;
            padding: 13px;
            text-align: left;
        }
        table#t01 th {
            width: 100%;
            background-color: orange;
            color: black;
            font-size: 20px;
            position: relative;                
        }
    </style>

//这是HTML代码

<div>
  <table id="t01">
    <tr class="header"> 
      <th>Name</th>
      <th>Download</th>
    </tr>
    <tr class="data_table"></tr> 
  </table>
</div>

最佳答案

你的 html 是错误的,使用:

   <table>
        <thead>
            <tr class='header'>
               <th>Name</th>
               <th>Download</th>
            </tr>
        <thead>
        <tbody>
            <tr class='data_table'>

            </tr>
        </tbody>
    </table>

关于html - 如何在html中设置表头和表数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52591984/

相关文章:

css - 如何使用 CSS 添加看起来像 div 每一侧边框的背景图像

html - 带标题的 3x3 圆形图标网格

html - 网格 960 : how to change width, 填充和边距?

javascript - 滚动到各自溢出的 div 中的几个元素

css - 现在使用 <br/> 标签已经过时了吗?如果是这样,我应该改用什么?

javascript - 表单将无法验证

html - 从 CSS 属性 :not() doesn't work 中排除类

javascript - 速记 http ://as//for script and link tags? 以前有人看到/使用过这个吗?

javascript - 如何在单个函数中定义多个任务并在 javascript 中使用

html - 具有重叠内容的背景图像取决于移动或桌面 View