


Emmet plug-in: HTML/CSS code quick writing artifact_html/css_WEB-ITnose
Emmet插件的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生。它使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度,比如下面的演示:
该插件已经改名为Emmet。但Emmet不只改名,还带来了一些新特性。本文就来直观地演示给你。
一、快速编写HTML代码
1. 初始化
HTML文档需要包含一些固定的标签,比如、
2. 轻松添加类、id、文本和属性
连续输入元素名称和ID,Emmet会自动为你补全,比如输入p#foo:
连续输入类和id,比如p.bar#foo,会自动生成:
Html代码
下面来看看如何定义HTML元素的内容和属性。你可以通过输入h1{foo}和a[href=#],就可以自动生成如下代码:
Html代码
3. 嵌套
现在你只需要1行代码就可以实现标签的嵌套。
效果如下图所示:
4. 分组
你可以通过嵌套和括号来快速生成一些代码块,比如输入(.foo>h1)+(.bar>h2),会自动生成如下代码:
Html代码
5. 隐式标签
声明一个带类的标签,只需输入div.item,就会生成
在过去版本中,可以省略掉div,即输入.item即可生成. Now if you only enter .item, Emmet will determine based on the parent tag. For example, if you enter .item in
- , will be generated.
- li: for ul and ol
- tr: used in table, tbody, thead and tfoot
- td: used in tr
- option: used in select and optgroup
- ;/ul> The element
- If you enter ul>li.item$*3, the following code will be generated:
- 2. CSS abbreviation
- 1. Value
- Maybe you have already known some abbreviations before, such as @f , can generate:
- font-family :;
- src:url();
- }
- font-family: 'FontName';
- src: url('FileName.eot ');
- src: url('FileName.eot?#iefix') format('embedded-opentype'),
- url('FileName.woff') format('woff' ),
- overflow :hidden; If you enter non-W3C standard CSS attributes, Emmet will automatically add the vendor prefix. For example, if you enter trs, it will generate:
- -webkit-super-foo: ;
- -moz-super-foo: ;
- -ms-super-foo: ;
- -o-super-foo: ;
- The prefix abbreviation is as follows:
- w means -webkit-
- Css code
- background-image: -o-linear -gradient(left, #fff 50%, #000);
- background-image: linear-gradient(left, #fff 50%, #000);
- Quote
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero delectus.
- Notepad
- PSPad
The following are all implicit tag names:
6. Define multiple elements
To define multiple elements, you can use the * symbol. For example, ul>li*3 can generate the following code:
Html code
;
//Of course, it is also possible to change it to ul>li#item$*3. The result is as follows
Css code
width: 100px;
In addition to px, other units can also be generated, such as inputting h10p m5e, the result is as follows:
height: 10%;
- margin: 5em;
p means %
e means em
px or no unit can be expressed as px // Added by Kerita
2. Additional attributes
Css code
Some other attributes, such as background-image, border-radius, Additional options such as font, @font-face, text-outline, text-shadow, etc. can be generated through the " " symbol. For example, entering @f will generate:
Css code
@font-face {
url('FileName.svg#FontName') format('svg');
font-style: normal;
3. Fuzzy matching
If you are not sure about some abbreviations, Emmet will match the closest syntax based on your input, such as entering ov: h, ov-h, ovh and oh, the generated code is the same:
Css code
Css code
-webkit-transform: ; -moz-transform: ;
-ms-transform: ;
transform: ; " symbol, you can also prefix the attribute. For example, enter -super-foo:
Css code
If you do not want to add all prefixes, you can use an abbreviation to specify, for example, -wm-trf means only adding -webkit and -moz prefixes:
Css code
-webkit-transform: ;
-moz-transform: ;
- transform: ;
s means -ms -
o means -o-
5. Gradient
Input lg(left, # fff 50%, #000), the following code will be generated:
background-image: -webkit-linear-gradient(left, # fff 50%, #000);
background-image: -moz-linear-gradient(left, #fff 50%, #000);
3. Additional functions
Generate Lorem ipsum text
Lorem ipsum refers to a Latin article commonly used in the field of typesetting design. The main purpose is to test the effect of the article or text in different fonts and layouts. With Emmet, you can generate these words simply by typing lorem or lipsum. You can also specify the number of characters, such as lorem10, which will generate:
You can also customize the Emmet plug-in:
To add a new abbreviation or update an existing abbreviation, modify the snippets.json file
To change the behavior of Emmet filters and operations, modify the preferences.json file to define how HTML is generated Or XML code, you can modify the syntaxProfiles.json file
5. Plug-ins for different editors
Sublime Text 2
TextMate 1.x
Eclipse/Aptana
Coda 1.6 and 2.x
Espresso
Chocolat (added through the "Install Mixin" dialog box)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...
