<table class="table table-hover"> <thead> <tr> <th>商品名称</th> <th>单价</th> <th>数量</th> <th>总价</th> <th>操作</th> </tr> </thead> <tbody> <div><tr> <td><img src="img/t_recommen/cup.jpg" width="200" height="150"><br>健身水杯 </td> <td>100</td> <td><input type="number" value="1" min="1"></td> <td>100</td> <td><button class="btn btn-danger">删除</button></td> </tr> <tr> <td><img src="img/t_recommen/xiaomi.jpg" width="200" height="150"><br>商品2</td> <td>200</td> <td><input type="number" value="1" min="1"></td> <td>200</td> <td><button class="btn btn-danger">删除</button></td> </tr> <tr> <td><img src="img/mobile/m2.jpg" width="200" height="150"><br>商品3</td> <td>300</td> <td><input type="number" value="1" min="1"></td> <td>300</td> <td><button class="btn btn-danger">删除</button></td> </tr> </tbody> <tfoot> <tr> <td colspan="3">总价:</td> <td colspan="2">600</td> </tr> </div> </tfoot> </table>让总体居中
时间: 2023-07-02 21:20:07 浏览: 167
要让整个表格居中,可以将表格放在一个 div 元素中,并给这个 div 元素添加 text-align: center 样式。也可以直接给表格添加 margin: 0 auto 样式,这样会使表格在水平方向上居中。以下是修改后的代码:
```html
<div style="text-align: center;">
<table class="table table-hover" style="margin: 0 auto;">
<thead>
<tr>
<th>商品名称</th>
<th>单价</th>
<th>数量</th>
<th>总价</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="img/t_recommen/cup.jpg" width="200" height="150"><br>健身水杯 </td>
<td>100</td>
<td><input type="number" value="1" min="1"></td>
<td>100</td>
<td><button class="btn btn-danger">删除</button></td>
</tr>
<tr>
<td><img src="img/t_recommen/xiaomi.jpg" width="200" height="150"><br>商品2</td>
<td>200</td>
<td><input type="number" value="1" min="1"></td>
<td>200</td>
<td><button class="btn btn-danger">删除</button></td>
</tr>
<tr>
<td><img src="img/mobile/m2.jpg" width="200" height="150"><br>商品3</td>
<td>300</td>
<td><input type="number" value="1" min="1"></td>
<td>300</td>
<td><button class="btn btn-danger">删除</button></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">总价:</td>
<td colspan="2">600</td>
</tr>
</tfoot>
</table>
</div>
```
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<html> <head> <title>人员管理界面</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script> </head> <body> 员工列表 —— 显示所有员工信息 ID 姓名 电话号 地址 职位 职位编号 状态 证件照 <c:forEach items="${employees}" var="employees"> ${employees.id} ${employees.name} ${employees.phonenumber} ${employees.address} ${employees.job} ${employees.jobid} ${employees.state} ![]()
更改 | 删除 </c:forEach> </body> </html>给这个界面的表格实现一个分页的功能,每页的最大数目为5
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<input type="checkbox" id="selectAll"> 学生编号 学生学号 学生姓名 学生性别 学生出生日期 学生地址 学生电话 学生照片 学生班级 操作 <c:forEach items="${list.list }" var="student" varStatus="status"> <input type="checkbox" name="idCheckbox" value="${student.stuId }"> ${student.stuId } ${student.stuNo} ${student.stuName } ${student.stuSex } ${student.stuBirth } ${student.stuAddress } ${student.stuPhone } ![]()
${student.classes.className } 美化一下
目录 菜系管理 菜谱管理 菜系列表 <button onclick="addCuisine()" class="btn btn1 btn1">添加</button> <button onclick="updateCuisine()" class="btn btn2 btn2"> 修改</button> <button onclick="deleteCuisineById()" class="btn btn3 btn3">删除</button> <input type="text" name="name" id="name" style="width: 10ch" class="inputText"> <button onclick="searchCuisineByName()" class="btn btn4 btn4">按姓名查询</button>
序号 菜名 所属地 口味 <input type="radio" th:value="${cuisine.id}" name="rid"> <form id="hiddenForm" method="post" th:action="@{/toUpdateCuisine}" hidden> <input type="text" name="id" id="formid"> </form> 美化页面导航条
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
目录 菜系管理 菜谱管理 菜系列表 <button onclick="addCuisine()" class="btn btn1 btn1">添加</button> <button onclick="updateCuisine()" class="btn btn2 btn2"> 修改</button> <button onclick="deleteCuisineById()" class="btn btn3 btn3">删除</button> <input type="text" name="name" id="name" style="width: 10ch" class="inputText"> <button onclick="searchCuisineByName()" class="btn btn4 btn4">按姓名查询</button>
序号 菜名 所属地 口味 <input type="radio" th:value="${cuisine.id}" name="rid"> <form id="hiddenForm" method="post" th:action="@{/toUpdateCuisine}" hidden> <input type="text" name="id" id="formid"> </form> 美化页面导航条
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)