Bootstrap table设置th,td内容水平、垂直居中

第一种:

.table th, .table td {
text-align: center;
vertical-align: middle!important;
}

第二种:直接在td,th标签里写

<th style="vertical-align: middle !important;text-align: center;">序号</th>
<td style="vertical-align: middle !important;text-align: center;">人员数量</td>
text-align属性值描述
left把文本排列到左边。默认值:由浏览器决定。
right把文本排列到右边。
center把文本排列到中间。
justify实现两端对齐文本效果。
inherit规定应该从父元素继承 text-align 属性的值。
vertical-align属性值描述
baseline默认。元素放置在父元素的基线上。
sub垂直对齐文本的下标。
super垂直对齐文本的上标
top把元素的顶端与行中最高元素的顶端对齐
text-top把元素的顶端与父元素字体的顶端对齐
middle把此元素放置在父元素的中部。
bottom把元素的顶端与行中最低的元素的顶端对齐。
text-bottom把元素的底端与父元素字体的底端对齐。
%使用 “line-height” 属性的百分比值来排列此元素。允许使用负值。
inherit规定应该从父元素继承 vertical-align 属性的值。
要使table th居中,可以使用以下方法: 1. 在<style>标签中添加样式,设置text-align属性为center,例如: <style> .table th { text-align: center; } </style> \[1\] 2. 在<th>标签中直接添加style属性,设置text-align属性为center,例如: <th style="text-align: center;">序号</th> \[3\] 3. 在<style>标签中添加样式,设置text-align属性为center,例如: <style type="text/css"> th { text-align: center; } </style> \[2\] 以上方法都可以将table th居中对齐。 #### 引用[.reference_title] - *1* [设置表头thtd居中](https://blog.csdn.net/TD520314/article/details/85060546)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [tableth内容水平垂直居中](https://blog.csdn.net/qasw460326327/article/details/80703066)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Bootstrap table设置th,td内容水平垂直居中](https://blog.csdn.net/weixin_45609759/article/details/107495097)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值