antd中的tree组件样式修改 react

react的中普通的树结构已经不满足样式的要求了,修改样式就得从组件内部的类名下手了,原来的样式,就是tree组件的普通样式:

修改后的样式:

树形结构需要进行展开折叠,所以这些情况都要考虑,插入一个图片需要用到::before进行插入,具体修改如下:


            >.ant-tree>.ant-tree-list>.ant-tree-list-holder>div>.ant-tree-list-holder-inner>.ant-tree-treenode {
                box-sizing: border-box;
                height: 56px;
                display: flex;
                align-items: center;
                font-size: 16px;
                border-top: 8px solid #f4f7fb;
                border-bottom: 8px solid #f4f7fb;
                box-shadow: 0 1px 1px 0 #161f520f;
                position: relative;
                padding-top: 6px;

                .ant-tree-draggable-icon {
                    display: none;

                }

                .ant-tree-switcher-noop {
                    display: none;
                }

                .ant-tree-switcher_open {
                    position: relative;
                }






            }

            .ant-tree-title {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                width: 90%;
            }

            .ant-tree-node-content-wrapper-normal {
                display: flex;
                align-items: center;
                position: relative;

                &:before {
                    content: '';
                    display: inline-block;

                    width: 12px;
                    height: 12px;

                    border-radius: 5px;
                    padding: 20px 15px 20px 25px;
                    background: #dce3ec url('./img/lock.png') center center no-repeat;
                    background-size: 12px 12px;
                    position: absolute;
                    left: 0;
                    z-index: 99;
                    transition: all 1s;

                }


                .ant-tree-title {
                    position: absolute;
                    left: 52px;
                }
            }

            .ant-tree-node-content-wrapper-open {
                display: flex;
                align-items: center;
                position: relative;

                &:before {
                    content: '';
                    display: inline-block;

                    width: 12px;
                    height: 12px;
                    border-radius: 5px;
                    padding: 20px 15px 20px 25px;
                    // background: #2a64ff url('./img/highLock.png') center center no-repeat;
                    background: #dce3ec url('./img/lock.png') center center no-repeat;
                    background-size: 12px 12px;
                    position: absolute;
                    left: 0;
                    z-index: 99;
                }

                .ant-tree-title {
                    position: absolute;
                    left: 52px;
                }
            }

            .ant-tree-node-content-wrapper-close {
                display: flex;
                align-items: center;
                position: relative;

                &:before {
                    content: '';
                    display: inline-block;

                    width: 12px;
                    height: 12px;

                    border-radius: 5px;
                    padding: 20px 15px 20px 25px;
                    background: #dce3ec url('./img/lock.png') center center no-repeat;

                    background-size: 12px 12px;
                    position: absolute;
                    left: 0;
                    z-index: 99;
                }

                .ant-tree-title {
                    position: absolute;
                    left: 52px;
                }
            }


            .ant-tree-node-selected {
                &:before {
                    content: '';
                    display: inline-block;

                    width: 12px;
                    height: 12px;

                    border-radius: 5px;
                    padding: 20px 15px 20px 25px;

                    background: #2a64ff url('./img/highLock.png') center center no-repeat;

                    background-size: 12px 12px;
                    position: absolute;
                    left: 0;
                    z-index: 99;
                    transition: all 1s;
                }
            }

            .ant-tree-switcher ant-tree-switcher_open {
                position: relative;
                z-index: 9999;
            }

            .ant-tree-node-selected {

                padding: 20px 0;

                border-radius: 8px !important;

                border: 1px solid #2A64FF;
                border-left: 0;

                background-color: #eef3ff !important;
                color: #202642;


            }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值