当某个链接或元素被选中时可以时,需要改变其颜色或状态,而stylus中提供&选择器,&指向父选择器,用于判断父元素达到某条件时改变状态,下面的例子中当父元素router-link有被选中(active)时,子元素改变颜色并加上下划线。

//html
<router-link tag="div" class="tab-item" to="/recommend">
   <span class="tab-link"></span>
</router-link>

//css
.tab-link
      padding-bottom: 5px
      color: #fff
&.router-link-active
  .tab-link
      color: #000
      border-bottom: 2px solid #000
原文链接:https://blog.csdn.net/tjzc1352640/article/details/78359863 

相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
猜你喜欢
  • 2022-01-17
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案