html Sass:占位符 - 存在()在Sass #sass中
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Sass:占位符 - 存在()在Sass #sass中相关的知识,希望对你有一定的参考价值。
<div class="warning">
<p>A Warning Message.</p>
</div>
.warning {
color: red;
}
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
// Sass: placeholder-exists() in Sass.
//
// Automatically placeholder-ize duplicated CSS declarations.
// https://gist.github.com/whizark/720ffec139368fa61932
//
// Other ideas
// https://github.com/whizark/xass#ideas
// List for Placeholder names.
$-placeholders: ();
// Returns whether a placeholder exists.
//
// Note: This cannot check nested (scoped) placeholders.
@function placeholder-exists($name) {
@if index($-placeholders, $name) == null {
@return false;
}
@return true;
}
// Registers a placeholder.
//
// @access private
@function -register-placeholder($name) {
@if placeholder-exists($name) {
@error 'The key `#{$name}` has already been registered.';
}
$-placeholders: append($-placeholders, $name) !global;
@return $name;
}
// Defines a placeholder.
@mixin define-placeholder($name) {
%#{$name} {
$name: -register-placeholder($name);
@content;
}
}
// Defines my own placeholder(s).
%important {} // A stub for IDE.
@include define-placeholder('important') {
color: red;
}
// Extends placeholder.
.warning {
@extend %important;
}
<div class="warning">
<p>A Warning Message.</p>
</div>
以上是关于html Sass:占位符 - 存在()在Sass #sass中的主要内容,如果未能解决你的问题,请参考以下文章
html Sass:自动占位符复制CSS声明。 #sass
html Sass:占位符工厂(Mixin)基于argumetns #sass
html 用Sass加载占位符
html Sass mixin / extend /占位符比较
Sass代码重用----Sass占位符
sass学习笔记:混合宏VS继承VS占位符