less 使用特性 - extend

船火儿
• 阅读 2236

1.extend

/* extend */
ul {
  &:extend(.inline);
  background: blue;
}
.inline {
  color: red;
}

output:

/* extend */
ul {
  background: blue;
}
.inline,
ul {
  color: red;
}

1.1 Extend Inside Ruleset

pre:hover,
.some-class {
  &:extend(div pre);
}

the same as:

pre:hover:extend(div pre),
.some-class:extend(div pre) {}

1.2 Extending Nested Selectors

.bucket {
  tr { // nested ruleset with target selector
    color: blue;
  }
}
.some-class:extend(.bucket tr) {}

output:

.bucket tr,
.some-class {
  color: blue;
}

1.3 nth Expression

[title=identifier] {
  color: blue;
}
[title='identifier'] {
  color: blue;
}
[title="identifier"] {
  color: blue;
}

.noQuote:extend([title=identifier]) {}
.singleQuote:extend([title='identifier']) {}
.doubleQuote:extend([title="identifier"]) {}

output:

[title=identifier],
.noQuote,
.singleQuote,
.doubleQuote {
  color: blue;
}

[title='identifier'],
.noQuote,
.singleQuote,
.doubleQuote {
  color: blue;
}

[title="identifier"],
.noQuote,
.singleQuote,
.doubleQuote {
  color: blue;
}

1.4 Extend "all"

.a.b.test,
.test.c {
  color: orange;
}
.test {
  &:hover {
    color: green;
  }
}

.replacement:extend(.test all) {}

output:

.a.b.test,
.test.c,
.a.b.replacement,
.replacement.c {
  color: orange;
}
.test:hover,
.replacement:hover {
  color: green;
}

1.5 Reducing CSS Size

第一种方式:

.my-inline-block() {
    display: inline-block;
  font-size: 0;
}
.thing1 {
  .my-inline-block;
}
.thing2 {
  .my-inline-block;
}

output:

.thing1 {
  display: inline-block;
  font-size: 0;
}
.thing2 {
  display: inline-block;
  font-size: 0;
}

第二种方式:

.my-inline-block {
  display: inline-block;
  font-size: 0;
}
.thing1 {
  &:extend(.my-inline-block);
}
.thing2 {
  &:extend(.my-inline-block);
}

output:

.my-inline-block,
.thing1,
.thing2 {
  display: inline-block;
  font-size: 0;
}
点赞
收藏
评论区
推荐文章
blmius blmius
4年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Caomeinico Caomeinico
4年前
shell-定义一个颜色输出字符串函数
写法1!/bin/bashfunctionechocolor()if$1"green";thenechoe"\03332;40m$2\0330m"elif$1"red";thenechoe"\03331;40m$2\0330m"fiechocolor
Wesley13 Wesley13
4年前
SASS基础
特点:1.在css基础上增加特性:变量、嵌套(nesting)、混合(@mixin)、继承(@extend);2.通过函数进行颜色值与属性值的运算;3.提供控制指令等高级功能;4.自定义输出指令;数据类型:Sass和JavaScript语言类似,也具有自己的数据类型,在Sass中包含以下几种数据类型:1\
Easter79 Easter79
4年前
stylus基础教程,stylus实例教程,stylus语法总结
stylus特点富于表现力、具有健壮性、功能丰富、动态编码不需要写CSS的冒号、分号、大括号和LESS、SASS功能类似,会这些的入手很快stylus特点安装使用stylus语法(一)选择器(二)变量(三)插值(四)运算符(五)内置函数(六)尾参数…(七)@extend继承
Dax Dax
4年前
Vue父子组件
几种常见的通信方式:1、prop属性父组件通过绑定属性的方式,给子组件传值,同时子组件通过设置props来接收letChildVue.extend(template:'content',props:content:type:String,default:()r
Easter79 Easter79
4年前
TP5+PHPexcel导入xls,xlsx文件读取数据
首先:在extend里面引入PHPexcel文件,直接根目录导入进去!(https://static.oschina.net/uploads/space/2018/0313/143438_OynF_3360064.png)html创建上传按钮<formclass"layuiform"method"post"action
Stella981 Stella981
4年前
Python获取 当前目录、上一级目录
<pre<spanstyle"color:0000ff"import</span<spanstyle"color:000000"os</span<spanstyle"color:0000ff"print</span<spanstyle"color:800000"'</span<spanstyle"c
Stella981 Stella981
4年前
Sass
嵌套规则(NestedRules)Sass允许将一套CSS样式嵌套进另一套样式中,内层的样式将它外层的选择器作为父选择器mainp{color:00ff00;width:97%;.redbox{
Stella981 Stella981
4年前
Javascript对象复制引用机制及$.extend复制特点
首先复习一下javascript中的变量类型基本类型numberstringbooleanundefinednull引用类型functionarraydate正则错误基本类型变量的复制,内容修改后,不会对另一变量产生影响vara
Stella981 Stella981
4年前
Pre
PAT甲级1119,我先在CSDN上面发布的这篇文章:https://blog.csdn.net/weixin\_44385565/article/details/89737224(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fblog.csdn.net%2Fweixin_443855