首页 > 其他分享 >@mixin 与 @include

@mixin 与 @include

时间:2022-12-06 09:55:33浏览次数:37  
标签:混入 font color bordered mixin include

@mixin 指令允许我们定义一个可以在整个样式表中重复使用的样式。

@include 指令可以将混入(mixin)引入到文档中。

 

定义混入

@mixin important-text {
  color: red;
  font-size: 25px;
  font-weight: bold;
  border: 1px solid blue;
}

使用混入

.danger {
  @include important-text;
  background-color: green;
}

结果

.danger {
  color: red;
  font-size: 25px;
  font-weight: bold;
  border: 1px solid blue;
  background-color: green;
}

 

向混入传递变量

/* 混入接收两个参数 */
@mixin bordered($color, $width) {
  border: $width solid $color;
}

.myArticle {
  @include bordered(blue, 1px);  // 调用混入,并传递两个参数
}

.myNotes {
  @include bordered(red, 2px); // 调用混入,并传递两个参数
}

混入也可以添加默认变量

@mixin bordered($color: blue, $width: 1px) {
  border: $width solid $color;
}

 

标签:混入,font,color,bordered,mixin,include
From: https://www.cnblogs.com/naxinqiu1/p/16954352.html

相关文章

  • 攻防世界-fileinclude
    一道简单的文件包含题目,源代码如下 一、代码分析此题中关键代码为  分析此处代码可知,$lan的值是cookie中language所对应的值,当该值不为english时,会将$lan的值与.p......
  • Vue 中 的 mixin 混入(合)
    Vue中的mixin混入(合)1:说明/*##mixin(混入)1.功能:可以把多个组件共用的配置提取成一个混入对象2.使用方式:第一步定义混合:```{dat......
  • vue全局引入scss(mixin)
    前言today,isgoodday,中午吃了个农民工外卖,有点撑,想在床上躺会,TMD,睁开眼天黑了,别说,冬天的上海天黑的挺早,基本上五点半就已经全黑了,住在出租屋的我,却感觉不到上海的灯火通......
  • (一)C++什么时候需要将#include写到头文件,什么时候需要写到cpp文件?
    https://www.zhihu.com/question/270945429首先.h和.cpp文件在编译器中是几乎一样不做区分的都是文件而已。其次#include的作用就相当于把引入文件中的所有内容完整的复......
  • Vue -- Mixin混入(二)
    前言使用Mixin混入自定义属性自定义属性:就是直接写在组件里的属性定义一个Mixin,并写入自定义属性 constmyMixin={num:1};创建vue实例,定义......
  • include_file
    环境简单明了,就一个include一个check.php,试探过滤,需要fuzzingpoc:php://filter/convert.iconv.UCS-2LE.UCS-2BE/resource=check.php再用编码器字典跑,试探可以发现......
  • #include头文件和class+ 类名的区别
    class类名只是声明存在这么一个类,但是通过这个声明无法得到任何关于此类的具体信息。这样你可以在其他使用到的地方声明一个该类型的指针。include头文件则是将整个该......
  • include<reg52.h>
    nclude是预编译指令,include<reg52.h>的作用就是将52单片机的头文件reg52.h嵌入源文件中。预处理器发现#include指令后,就会寻找指令后面<>中的文件名,并把这个文件的内容......
  • 14.<include>标签的使用
    1.正常情况下使用sql标签用作封装参数或Sql块<sqlid="Param_Block"><!--名字随便起--> id, name, phone</sql><!--或者--><sqlid="Param_Block"> OR......
  • [Bug0052] Hexo+Butterfly博客报错extends includes/layout.pug block content includ
    问题Hexo主题Butterfly启动后报错extendsincludes/layout.pugblockcontentinclude./includes/mixins/post-ui.pug#recent-posts.recent-posts+postUIincludein......