visibility-伪对象

    visibility:显示隐藏;
			hidden	隐藏
			visible	显示
			
	visibility 和 display 的区别
		1: 都可以显示隐藏元素
		2: visibility:hidden;	占据文档流
			display:none;	脱离文档流
				
	伪对象:
		:after{content:"";}	在....之后,伪装一个元素,可以添加样式
		:before{content:"";}在....之前,伪装一个元素,可以添加样式
		:first-letter{}针对第一个字设置样式,只应用块级元素
		:first-line{}针对第一行字设置样式,只应用于块级元素
### 修改 `a-tree` 组件连接线样式的实现方法 为了自定义 Ant Design Vue 中 `a-tree` 组件的连接线样式,可以采用多种方式来覆盖默认样式并应用新的设计。以下是具体的方法: #### 使用 CSS 覆盖默认样式 通过全局或局部的方式引入特定的选择器来调整 `.ant-tree-treenode-switcher-icon` 和其他关联类名下的属性。 ```css /* 自定义 a-tree 连接线 */ .ant-tree li span.ant-tree-treenode-switcher { background-color: transparent; } .ant-tree li .ant-tree-treenode-switcher::before, .ant-tree li .ant-tree-treenode-switcher::after { content: &#39;&#39;; position: absolute; top: 50%; transform: translateY(-50%); width: 1px; height: calc(100% - 28px); background-color: #e6e6e6; } .ant-tree li .ant-tree-treenode-switcher::before { left: -7px; } .ant-tree li .ant-tree-treenode-switcher::after { bottom: 0; } ``` 上述代码片段展示了如何利用伪元素 `::before` 和 `::after` 来创建自定义线条效果[^2]。 #### 结合 scoped 样式作用域 如果是在单文件组件 (SFC) 内部工作,则可以通过添加 `scoped` 属性使样式仅应用于当前组件内的 HTML 元素,从而避免影响到页面上的其它部分。 ```html <template> <!-- Tree Component --> </template> <style lang="scss" scoped> @import &#39;~ant-design-vue/es/tree/style/index&#39;; .TreeWithSwitch { /* ...原有样式 */ .ant-tree { li { .ant-tree-treenode-switcher { &:not(.ant-tree-treenode-loading):not(.ant-tree-treenode-selected){ color: blue !important; &::before, &::after{ background-color: red !important; // 改变连接线颜色为红色 } } } .ant-tree-node-content-wrapper:hover { button.operation-btns { visibility: visible; } } @at-root #{&} .operation-btns { visibility: hidden; float:right; } } } } </style> ``` 这段 SCSS 代码不仅改变了连接线的颜色,还增加了节点悬停时显示操作按钮的功能[^3]。 #### 动态绑定 class 或 style 对于更复杂的场景,比如根据不同条件动态改变连接线样式的情况,可以在模板中使用 v-bind 指令传递内联样式对象或者额外的 className 到子组件上。 ```javascript // JavaScript/TypeScript 配置逻辑... data() { return { customLineStyle: { backgroundColor: &#39;green&#39;, borderColor: &#39;#ffcc00&#39; }, dynamicClass: computed(() => ({ [&#39;custom-line&#39;]: someConditionMet(), [&#39;alternative-style&#39;]: anotherCondition() })) }; }, methods: { handleNodeClick(nodeInfo) { console.log(&#39;Clicked node:&#39;, nodeInfo); } } ``` ```html <a-tree :class="[dynamicClass]" :style="customLineStyle" /> ``` 此法允许基于业务逻辑灵活控制渲染结果中的实际表现形式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值