Getting to know less and grammar

1.less official website:
English: http: //www/lesscss.org/
Chinese: HTTP: //www.lesscss.net/
2.less.js Downloads:
I. enter the URL: http: //www.lesscss. net
II. click the update log
Here Insert Picture Description
III. click less.js
Here Insert Picture Description
IV. click on the right of the download zip
Here Insert Picture Description
V. found in the download archive to the folder
Here Insert Picture Description
of June. find less opening the file, dist / less
VII. the less.min.js copy the file to the project
eight introduced in the project's home page:
Here Insert Picture Description
If you do not, then introduced less.min.js, css will have no effect
3.less variable (with sass similar usage)
a common variable.

@width: 10px;
@height: @width + 10px;

#header {
  width: @width;
  height: @height;
}
编译为:

#header {
  width: 10px;
  height: 20px;
}

II. As a selector and attribute names
to @ (variable names) used when using a variable manner
Here Insert Picture Description
three as the URL
Here Insert Picture Description
4. mixing
the mixed (Mixin) A is a set of attributes from a rule set containing (or mixed) to another the method of rule sets

.bordered {
  border-top: dotted 1px black;
  border-bottom: solid 2px black;
}
如果我们希望在其它规则集中使用这些属性,我们只需像下面这样输入所需属性的类(class)名称即可,如下所示:

#menu a {
  color: #111;
  .bordered();
}

.post a {
  color: red;
  .bordered();
}
.bordered 类所包含的属性就将同时出现在 #menu a 和 .post a 中了

5.Less provides the use of nested (nesting) instead of the layered or laminated in combination with the ability to use.

#header {
  color: black;
}
#header .navigation {
  font-size: 12px;
}
#header .logo {
  width: 300px;
}
用 Less 语言我们可以这样书写代码:

#header {
  color: black;
  .navigation {
    font-size: 12px;
  }
  .logo {
    width: 300px;
  }
}

Using this method the pseudo-selectors (pseudo-selectors) used with mixing (mixins):

.clearfix {
  display: block;
  zoom: 1;

  &:after {
    content: " ";
    display: block;
    font-size: 0;
    height: 0;
    clear: both;
    visibility: hidden;
  }
}
Released four original articles · won praise 0 · Views 54

Guess you like

Origin blog.csdn.net/yanghongyan001/article/details/104432474