css中before和last-child一起使用或者after和first-child一起使用

今天遇到一个需求!!!!往我下面看……(想啥呢?看图!!!)

 

没错!!就是你看到的这三个有点黑黑的点……(不要在意细节!)

我是用ul无序列表写的。在li里面设置before和after弄成中线的线条(无缝连接呀);好吧回归正题。

我的想法是:第一个点的上面和最后一个点下面没有连接线。所以我刚开始想到的是:

disc-item::before:first-child{condent:" ";display:none;}

然而这是没啥用的-。。。!哈哈!!!!

好吧,知道你急了,死鬼别那么猴急嘛!!!嗯嗯……来正经的:loooooo……k

.disc-item:first-child::before{content:"";display:none;}

你大爷!似乎没啥改变嘛,只是我们添加伪类的时候顺序改变了。!可能你的效果还是无法正常:

让你看一下人家的啦……!!!

.notice_item::after{
	display: block;content:" ";
	background-color: #9b9b9b;width:2px;
	position:absolute;left:13px;top:0;bottom:50%;	z-index:20;}


.notice_item::before{
	display: block;content:" ";
	background-color: #9b9b9b;width:2px;
	position:absolute;
	left:13px;top:50%;bottom:0;z-index:20;}


.notice_item:last-child::before{display: none;content: "";}

.notice_item:first-child::after{display: none;content: "";}

在用这玩意之前要做好安全工作哦!……额……

你的浏览器等级要高一点点……抬高点了----嗯……!!!!

/deep/ .ant-tree { position: relative; /deep/ &::before { content: ''; width: 1px; height: 100%; height: calc(100% - 35px); position: absolute; border-left: 1px solid #d9d9d9; left: -6px; top: 18px; } /deep/ .ant-tree-treenode-switcher-open, /deep/ .ant-tree-treenode-switcher-close { position: relative; } >li:first-child:nth-last-child(1)::after { border: 0; } } /deep/ .ant-tree-treenode-switcher-close::after, /deep/ .ant-tree-treenode-switcher-open::after { content: ''; width: 8px; height: 1px; position: absolute; border-top: 1px solid #d9d9d9; left: -6px; top: 18px; } /deep/ .ant-tree > li:last-child::after { content: ''; width: 8px; height: 100%; border-top: 1px solid #d9d9d9; background-color: #fff; position: absolute; left: -6px; top: 18px; } /deep/ .ant-tree-treenode-switcher-close::before{ border: 0 !important; } /deep/.ant-tree-child-tree.ant-tree-child-tree-open > li:first-child { padding-top: 4px; } .last-menu-line() { position: absolute; left: 12px; width: 1px; height: 100%; margin: 22px 0 0; border-left: 1px solid #d9d9d9; content: ' '; } ul.ant-tree.icon-tree /deep/li { & > .ant-tree-checkbox { margin-left: 24px; & + .ant-tree-node-content-wrapper > .ant-tree-title { > i:nth-child(1) { position: absolute; left: -42px; top: 5px; } } } } ul.ant-tree /deep/li { position: relative; &:nth-last-child(1) { /deep/&.ant-tree-treenode-switcher-open::before { .last-menu-line; height: calc(100% - 46px); } } &:before { position: absolute; left: 12px; width: 1px; height: 100%; height: calc(100% - 42px); margin: 22px 0 0; border-left: 1px solid #d9d9d9; content: ' '; } .ant-tree-node-content-wrapper { padding: 0; position: relative; } ul.ant-tree-child-tree.ant-tree-child-tree-open > li { &::after { content: ''; position: absolute; width: 8px; height: 1px; border-top: 1px solid #d9d9d9; background: transparent; top: 15.5px; left: -5px; margin: 0; } &:nth-last-child(1) { &.ant-tree-treenode-switcher-open::before { .last-menu-line; height: calc(100% - 37px); } } } span.ant-tree-switcher { background: rgba(0, 0, 0, 0); } } div ul.ant-tree /deep/li.ant-tree-treenode-switcher-open { > ul.ant-tree-child-tree-open > li:nth-last-child(1) > ul::before { content: ''; width: 1px; height: 100%; position: absolute; background: #fff; left: -6px; top: 16px; } > ul.ant-tree-child-tree-open > li:nth-last-child(1) > span { &.ant-tree-node-content-wrapper::before { content: ''; width: 1px; position: absolute; background: #fff; left: -30px; top: 13px; height: calc(100% + 10px); } &.ant-tree-checkbox + .ant-tree-node-content-wrapper::before { top: 13px; left: -52px; } } > .ant-tree-node-content-wrapper-normal::before { content: ''; width: 1px; height: 100%; position: absolute; background: #fff; left: -12px; top: 16px; } }vue3写法
最新发布
06-27
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值