【问题标题】:How to use pseudo selectors like ::before in vuejs scoped style如何在 vuejs 范围样式中使用 ::before 之类的伪选择器
【发布时间】:2021-12-11 17:03:06
【问题描述】:

考虑以下样式:

<template>
  <!-- Some Tags -->

 <div class="mb-8 w-full">
   <span class="subline"></span>
 </div>

</template>

.
.
.


<style scoped lang="scss">

.subline {
  border-bottom: dashed 2px #eee;
  display: block;
}

.subline::before { /* Not working ! */
  width: 30px;
  height: 20px;
  z-index: 99999;
  border-bottom: dashed 2px green;
  position: fixed;
  bottom: 0;
  left: 0;
}
</style>

我需要使用::before 但不起作用!

我怎样才能做到这一点?

【问题讨论】:

标签: css vue.js sass vuejs3 scoped


【解决方案1】:

伪元素需要content 属性可见,添加content: "" 解决此问题

.subline::before {
  content: "";
  width: 30px;
  height: 20px;
  z-index: 99999;
  border-bottom: dashed 2px green;
  position: fixed;
  bottom: 0;
  left: 0;
}

【讨论】:

  • 谢谢,我真的忘记了
猜你喜欢
  • 1970-01-01
  • 2021-09-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-07
  • 2016-07-23
  • 2018-04-04
  • 1970-01-01
相关资源
最近更新 更多