【问题标题】:why does border in SCSS does not show on website [duplicate]为什么 SCSS 中的边框不显示在网站上 [重复]
【发布时间】:2022-11-19 11:05:40
【问题描述】:

我正在做一个有角度的项目,我正在努力制作我的菜单。

我的 SCSS:

// Small tablets and large smartphones (landscape view)
$screen-sm-min: 576px;

// Mixins
// Small devices
@mixin sm {
  @media (min-width: #{$screen-sm-min}) {
      @content;
  }
}

ul{
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: end;
  align-items: center;
  list-style: none;
  @include sm{
    display: block;
    position: relative;
    &:before{
      position: absolute;
      content: '';
      background-color: red;
      border-radius: 50rem;
      width: 40px;
      height: 40px;
    }
  }

  li{
    margin-left: 5px;
    margin-right: 5px;
    @include sm{
      margin: 0;
      padding-top: 40px;
      padding-left: 40px;
      position: relative;
      transform: translateY(40px);
      &:before{
        position: absolute;
        content: '';
        background-color: red;
        height: 100%;
        width: 20px;
        left: 20px;
        top: -10px;
        display: block;
        border: 5px blue !important;
        border-radius: 0 0 0 50rem;
      }
      &:after{
        position: absolute;
        content: '';
        background-color: red;
        height: 100%;
        width: 2px;
        left: 20px;
        top: -5px;
        display: block;
      }
      a{
        height: 20px;
        display: flex;
        align-items: center;
      }
    }
  }
}

如您所见,当屏幕大于 576 像素时,我的列表项的 :before 伪元素上有一个蓝色边框。 还有我的 HTML:

<ul>
  <li><a [routerLink]="['/']">Home</a></li>
  <li><a [routerLink]="['/watchlist']">Watchlist</a></li>
  <li><a [routerLink]="['/movies']">All movies</a></li>
  <li><a [routerLink]="['/aboutMe']">About me</a></li>
</ul>

给出结果:

在检查元素上我确实在伪元素上有边框

我想要的结果

有谁知道我的错误是什么以及为什么我的伪元素上没有边框?

【问题讨论】:

  • 从本质上讲,这是一个 HTML 和 CSS 问题。您可以使用编辑器将它们放入演示中。这可能只是一个 CSS 选择器特异性问题。
  • border需要边框样式属性:border: blue 5px solid
  • 谢谢 现在我讨厌自己 :)

标签: html css angular


【解决方案1】:

border需要边框样式属性:border: blue 5px solid;

【讨论】:

  • 我不会只是复制我的评论并将其添加为您的答案。这是一个基于错字的问题,可能应该删除。我认为 SO 上也有几个重复项。 stackoverflow.com/questions/42497049/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-04
  • 2014-07-23
  • 1970-01-01
  • 2023-03-26
  • 2012-03-25
相关资源
最近更新 更多