【问题标题】:Style HTML Table into Body of Page with Separate Header and Footer files using CSS使用 CSS 将 HTML 表格样式设置为带有单独页眉和页脚文件的页面正文
【发布时间】:2023-03-18 16:48:01
【问题描述】:

我在我的网页中使用单独的页眉和页脚文件,我已将 CSS 文件包含在页眉和页脚文件中。现在我想在我的页面中设置一个表格的样式,即想要添加垂直和水平滚动条。

下面是我的插图。

---------------------------------------------------------------------
|                header foo1.php                                    |
|    <link rel="stylesheet" type="text/css" href="myStyle.css">     |   
|-------------------------------------------------------------------|
| Body            foo2.php                                          |
|   **Table placed Here**                                           |
|                                                                   |
--------------------------------------------------------------------- 
|            Footer foo3.php                                        |
|    <link rel="stylesheet" type="text/css" href="myStyle.css">     |
|                                                                   |
---------------------------------------------------------------------

页脚和页眉使用正文不使用的 CSS 文件。

下面是表格的代码。

   <div id=wrapper>
  <table id=wrapper >
<tr>
<td>&nbsp;</td>
<td colspan="6"><strong>Update data in mysql</strong> </td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
            <tr>
                <td align="center">&nbsp;</td>
                <td align="center"><strong>ID</strong></td>
                <td align="center"><strong>FirstName</strong></td>
                <td align="center"><strong>Lastname</strong></td>
                <td align="center"><strong>Request</strong></td>
                <td align="center"><strong>Purpose</strong></td>
                <td align="center"><strong>Description</strong></td>
                <td align="center"><strong>Booking Time</strong></td>
                <td align="center"><strong>Access Time</strong></td>
                <td align="center"><strong>Exit Time</strong></td>
                <td align="center"><strong>Approved</strong></td>
                <td align="center"><strong>Approved By</strong></td>
            </tr>
<tr>
<td>&nbsp;</td>
<td align="center">
<input name="id" type="text" id="id" value="<?php echo $rows['id']; ?>">
</td>

<td align="center">
<input name="firstname" type="text" id="firstname" value="<?php echo $rows['fisrt_name']; ?>">
</td>
<td align="center">
<input name="lastname" type="text" id="lastname" value="<?php echo $rows['last_name']; ?>" size="15">
</td>
<td>
<input name="description" type="text" id="description" value="<?php echo $rows['description']; ?>" size="15">
</td>
<td>
<input name="description" type="text" id="request" value="<?php echo $rows['request']; ?>" size="15">
</td>
<td>
<input name="description" type="text" id="description" value="<?php echo $rows['description']; ?>" size="15">
</td>
<td>
<input name="description" type="text" id="booking_time" value="<?php echo $rows['booking_time']; ?>" size="15">
</td>
<td>
<input name="description" type="text" id="access_time" value="<?php echo $rows['access_time']; ?>" size="15">
</td>
<td>
<input name="description" type="text" id="exit_time" value="<?php echo $rows['exit_time']; ?>" size="15">
</td>
<td>
<input name="description" type="text" id="approved" value="<?php echo $rows['approved']; ?>" size="15">
</td>
<td>
<input name="description" type="text" id="approved_by" value="<?php echo $rows['approved_by']; ?>" size="15">
</td>


</tr>
<tr>
<td>&nbsp;</td>
<td>
<input name="id" type="hidden" id="id" value="<?php echo $rows['id']; ?>">
</td>
<td align="center">
<input type="submit" name="Submit" value="Submit">
</td>
<td>&nbsp;</td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>

下面是 CSS 的代码

div.wrapper{
height:500px;
widht:500px;
overflow:auto;

}

下面是页面的当前图片

【问题讨论】:

  • 您有什么问题?你需要发布你想要的结果。
  • 另外,您只需在标题中包含相同的 css 文件。
  • 我无法使表格可滚动,也无法固定表格的高度和宽度
  • 这是一个重复的问题。在它关闭之前,这里有一个链接 w3schools.com/html/html_tables.asp 。你需要花很多时间学习css。在提出问题之前始终进行搜索。
  • 一个id应该分配一次。并且div.wrapper 不匹配div#wrapper

标签: css html


【解决方案1】:

您的tablediv 元素具有相同的ID。不能有两个元素具有相同的ID。如果您想给他们两个同名(在您的情况下为wrapper),则将 ID 更改为 class。所以,给他们一个类名wrapper 并删除ID 名称。

【讨论】:

  • 感谢更正,但问题仍然存在。 Ok 将添加一张桌子的图片。
猜你喜欢
  • 2019-03-22
  • 2013-05-22
  • 1970-01-01
  • 2012-03-10
  • 1970-01-01
  • 1970-01-01
  • 2010-09-27
  • 1970-01-01
  • 2018-12-10
相关资源
最近更新 更多