html表格添加排序图标,bootstrap-table 自定义排序图标

本文介绍了如何在bootstrap-table中修改排序图标。首先在表头插入span元素,并根据排序状态添加'both'类。接着修改bootstrap-table.css,移除原有图片样式并添加自定义样式。最后展示了用于升序和降序的自定义CSS代码,通过调整边框来创建箭头效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

bootstrap-table 修改排序图标

一、修改bootstrap-table.js

1、在表头插入span元素,根据是否启用表格排序添加class=‘both’(为排序箭头做准备)bf3d4e851b5eeaa3abb16dded4fc5f58.png

164eab92199ee53430dd56435b8684a6.png

4cf20d1a76764ebff604906970b05466.png

2、将removeClass(‘desc asc’)改为removeClass(‘both desc asc’)(为后面写样式准备)c5e2917e6aa5822e74af23d4c549f8bd.png

二、修改bootstrap-table.css

1、去掉以图片作为排序图标样式

c6c878dff3b04a1905bdce7b68631dae.png

2、添加自定义样式

2c3732b616d0d896a0351d16b6dddefb.png

三、结果

2ab80565e318671c3927366fb0b4835d.png

自定义样式代码

.fixed-table-container thead th .both > .both{

margin-left: 15px;

display: inline-block;

position: relative;

}

.fixed-table-container thead th .both > .both:before{

content: ”;

display: inline-block;

border-left: 4px solid transparent;

border-right: 4px solid transparent;

border-bottom: 4px solid #000;

vertical-align: middle;

position: absolute;

left: -4px;

top:-10px

}

.fixed-table-container thead th .both > .both:after{

content: ”;

display: inline-block;

border-left: 4px solid transparent;

border-right: 4px solid transparent;

border-top: 4px solid #000;

vertical-align: middle;

position: absolute;

left: -4px;

top:-4px

}

.fixed-table-container thead th .asc >.both{

margin-left: 12px;

display: inline-block;

border-left: 4px solid transparent;

border-right: 4px solid transparent;

border-bottom: 4px solid #000;

vertical-align: middle;

position:static;

}

.fixed-table-container thead th .desc >.both{

margin-left: 12px;

display: inline-block;

border-left: 4px solid transparent;

border-right: 4px solid transparent;

border-top: 4px solid #000;

vertical-align: middle;

position:static;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值