- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 mac osx 上使用 compass 管理一些 sass 文件。我有这些文件:
sass/
screen.scss
partials folder/
...
_fonts.scss
_functions.scss
...
在字体中我有这个规则,我想重用@extend。
//fonts.scss
.icon-ab-logo, {
font-family: 'icomoon';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
}
.icon-ab-logo:before { //i want to reuse this.
content: "\e000";
}
在函数中我有这个 screen.scss:
.logo {
position: absolute;
top: 0;
bottom: 0px;
z-index: 500;
width: 9.5em;
background: $logo;
@include transition(all 0.2s);
&:after{
@include icon( ".icon-ab-logo" );
}
}
最后在 functions.scss 中我称之为:
@mixin icon( $icon ){
font-family: 'icomoon';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
@extend #{$icon}:before; //<- this is the problem, no errors just isn't parsed.
}
有没有办法在使用 mixin 之前引用 .icon-ab-logo: ?解决方法?感谢阅读。
最佳答案
当您想扩展伪类或伪元素时,您只想扩展父选择器(即冒号之前的所有内容)。
%foo:before {
color: red;
}
.bar {
@extend %foo;
}
生成:
.bar:before {
color: red;
}
所以对于你的例子,你想要做的是:
.icon-ab-logo, {
font: 100%/1 'icomoon'; // use the shorthand
speak: none;
text-transform: none;
-webkit-font-smoothing: antialiased;
}
%foo:before, .icon-ab-logo:before { //i want to reuse this.
content: "\e000";
}
@mixin icon( $icon ){
font: 100%/1 'icomoon'; // use the shorthand
speak: none;
text-transform: none;
-webkit-font-smoothing: antialiased;
@extend #{$icon};
}
.bar {
@include icon('%foo');
}
请注意,您的 mixin 会生成很多 样式,因此它不太适合广泛重用。扩展它也会更有意义。
关于function - Sass 使用伪选择器扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27014882/
我实际上正在尝试构建一个 gulp 计划来做网络相关的事情,比如编译 sass、缩小 css、丑化 javascript 等等。但我真的在使用 sass 时遇到了麻烦。 这是我的代码示例: gulp.
为了简化样式的描述,浏览器设计了 css 作为 DSL(领域特定语言)。css 写起来简单,但在很多方面都不太方便,比如不支持嵌套,代码比较冗余;不支持继承和混合,代码不好复用等。 为了给 c
如何编译sass模块(新版sass)? https://css-tricks.com/introducing-sass-modules/ 我尝试了 sass-migrator 终端,但它没有编译 ht
在 SASS 中,当出现错误时,它会在浏览器的页面顶部显示一条消息。它的一个样本在附图中。 该文本不可选择。它不是图像。它不会出现在“查看源代码”中。它在 Firebug 中不可见。 错误文本是如何呈
我想决定何时编译.sass文件。换句话说,我不想看文件,而是手动编译。 我该怎么做? 最佳答案 它比我想象的要简单: sass style.scss style.css 关于sass - 我如何在不观
我希望有一个像 +stacktextshadow(blue, red, green) 这样的 mixin吐了text-shadow: 1px 1px 0 blue, 2px 2px 0 red, 3p
我想在我们公司的 Web 应用程序上使用 SASS,但我无法在生产机器上安装任何程序。我搜索的有关 SASS 的所有内容都需要您运行 gem 之类的安装程序,并且还需要 HAML。 我希望找到一个脚本
From the docs我看到您可以更改 SASS 的缓存位置。 但是,我不确定要使用的确切语法。我有一个 Zurb 基金会项目,随之而来的是一个 config.rb文件。我认为这是需要更新以更改缓
也许更好的问题是,有没有更有效的方法来覆盖 mixin 的一部分? 这段SCSS: @mixin button { .button { background-color: red;
我正在使用多行注释 /** 常见样式请看这里*/样式定义继续... 我在编译时遇到错误。它说: Error: Invalid CSS after "*/": expected identifier,
我正在尝试在 Nuxt.js 中使用 sass 包而不是 node-sass 。我找到了这样的配置; // vue.config.js module.exports = { css: {
我正在使用多行注释 /** 常见样式请看这里*/样式定义继续... 我在编译时遇到错误。它说: Error: Invalid CSS after "*/": expected identifier,
我正在尝试在 Nuxt.js 中使用 sass 包而不是 node-sass 。我找到了这样的配置; // vue.config.js module.exports = { css: {
重复问题? 是的。但与this有点不同 概述: 我也是括号文本编辑器的新用户。我知道 Scss 和 Sass 之间的区别。但是我使用方括号文本编辑器的原因只是为了 Sass 而不是 Scss。 看了J
我正在寻找像 +stacktextshadow(blue, red, green) 这样的 mixin text-shadow: 1px 1px 0 blue, 2px 2px 0 red, 3px
我决定删除 node-sass来自我的 gatsby 项目并使用 sass反而。我遵循了所提到的here对于 v3。我删除了 node-sass现在我的 package.json 中有这些版本: "g
我正在使用 vanilla Sass(没有 Compass/SUZY/Bourbon/etc.),但我无法确定将 *.rb 文件放在哪里。我不是 Ruby 程序员,但我确实找到了一个其他人编写的函数,
我刚开始使用gulp-sass ,是否有一种“简单”的方法来找出正在使用的 Sass 版本? 并不是说我认为这太重要了,但我正在使用 gulp-sass在 Visual Studio 2015 (CT
我正在为 sass 实现 grunt 插件到 css 处理,但有 2 个选项可用 grunt-contrib-sass 和 grunt-sass。 我在互联网上搜索但找不到任何相关答案 grunt-c
我试图在 Angular 项目中使用 CSS 变量和 Sass 函数(准确地说是 lighten()/darken()),据我所知,最新版本的 LibSass 允许这样做。 我已安装 node-sas
我是一名优秀的程序员,十分优秀!