angular - Sass 伪选择器在 Angular 中不起作用

标签 angular sass frontend primeng angular7

enter image description here

我正在尝试使用 Sass 实现图像中显示的样式。我使用 h1 标签和 :after psuedo-selector 来创建这一行。但是 :after 不起作用。我可以在 React 中实现这种风格。我正在将 Angular7 与 angular-cli 一起使用。

<h1 class="login">Login</h1>

.login {
    margin-top: 0;
    position: relative;
    &:after {
        display: block;
        border-bottom: 4px solid #faaf4a;
        bottom: 0;
        left: 0;
        position: absolute;
        width: 40px;
    }
}

请帮助我...

最佳答案

您必须添加 content:""; 属性。

<h1 class="login">Login</h1>

.login {
    margin-top: 0;
    position: relative;
    &:after {
        content: "";
        display: block;
        border-bottom: 4px solid #faaf4a;
        bottom: 0;
        left: 0;
        position: absolute;
        width: 40px;
    }
}

关于angular - Sass 伪选择器在 Angular 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54740744/

相关文章:

javascript - Sass.js在线编译

javascript - Angular JS,工厂返回数据,但在 Controller 中它消失了

node.js - 如果前端使用 SSL,Nodejs 是否需要额外的安全措施?

html - 如何为复选框标签添加一致的左边距?

javascript - Angular2 和 SystemJS : Cannot find module while building a moduleLoader

angular - 使用 FileSaver 和 blob 将响应正文另存为文件

reactjs - 在 CSS 模块中使用 SCSS 变量

reactjs - 为什么将 Electron 与 SPA 框架结合使用?

angular - 如何使用 angular2 设置验证器不接受索引 0 的选定选项

css - Sublime Text 创建 SASS - Autoprefixer - CSS 链保存时无需 Grunt