Home > Web Front-end > HTML Tutorial > 前端开发必备

前端开发必备

WBOY
Release: 2016-06-24 11:20:17
Original
1334 people have browsed it

介绍

Emmet (前身为 Zen Coding) 是一个能大幅度提高前端开发效率的一个工具。

基本上,大多数的文本编辑器都会允许你存储和重用一些代码块,我们称之为“片段”。虽然片段能很好地推动你得生产力,但大多数的实现都有这样一个缺点:你必须先定义你得代码片段,并且不能再运行时进行拓展。

Emmet把片段这个概念提高到了一个新的层次:你可以设置CSS形式的能够动态被解析的表达式,然后根据你所输入的缩写来得到相应的内容。Emmet是很成熟的并且非常适用于编写HTML/XML 和 CSS 代码的前端开发人员,但也可以用于编程语言。

示例

在编辑器中输入缩写代码ul>li*5,然后按下拓展键(默认为tab),即可得到代码片段:

<ul>    <li></li>    <li></li>    <li></li>    <li></li>    <li></li></ul>
Copy after login
Copy after login

下载和安装

编辑器插件

以下都是Emmet为编辑器提供的安装插件。

Sublime Text

Eclipse/Aptana

TextMate

Coda

Espresso

Chocolat

Komodo Edit

Notepad++

PSPad

textarea

CodeMirror

Brackets

NetBeans

Adobe Dreamweaver

在线编辑器的支持:

JSFiddle

JS Bin

CodePen

ICEcoder

Divshot

Codio

第三方插件的支持

下面这些编辑器的插件都是由第三方开发者所提供的,所以可能并不支持所有Emmet的功能和特性。

SynWrite

WebStorm

PhpStorm

Vim

HTML-Kit

HippoEDIT

CodeLobster PHP Edition

TinyMCE

语法

后代:>

nav>ul>li

<nav>    <ul>        <li></li>    </ul></nav>
Copy after login

兄弟:+

div+p+bq

<div></div><p></p><blockquote></blockquote>
Copy after login

上级:^

div+div>p>span+em^bq

<div></div><div>    <p><span></span><em></em></p>    <blockquote></blockquote></div>
Copy after login

div+div>p>span+em^^bq

<div></div><div>    <p><span></span><em></em></p></div><blockquote></blockquote>
Copy after login

分组:()

div>(header>ul>li*2>a)+footer>p

<div>    <header>        <ul>            <li><a href=""></a></li>            <li><a href=""></a></li>        </ul>    </header>    <footer>        <p></p>    </footer></div>
Copy after login

(div>dl>(dt+dd)*3)+footer>p

<div>    <dl>        <dt></dt>        <dd></dd>        <dt></dt>        <dd></dd>        <dt></dt>        <dd></dd>    </dl></div><footer>    <p></p></footer>
Copy after login

乘法:*

ul>li*5

<ul>    <li></li>    <li></li>    <li></li>    <li></li>    <li></li></ul>
Copy after login
Copy after login

自增符号:$

ul>li.item$*5

<ul>    <li class="item1"></li>    <li class="item2"></li>    <li class="item3"></li>    <li class="item4"></li>    <li class="item5"></li></ul>
Copy after login

h$[title=item$]{Header $}*3

<h1 title="item1">Header 1</h1><h2 title="item2">Header 2</h2><h3 title="item3">Header 3</h3>
Copy after login

ul>li.item$$$*5

<ul>    <li class="item001"></li>    <li class="item002"></li>    <li class="item003"></li>    <li class="item004"></li>    <li class="item005"></li></ul>
Copy after login

ul>li.item$@-*5

<ul>    <li class="item5"></li>    <li class="item4"></li>    <li class="item3"></li>    <li class="item2"></li>    <li class="item1"></li></ul>
Copy after login

ul>li.item$@3*5

<ul>    <li class="item3"></li>    <li class="item4"></li>    <li class="item5"></li>    <li class="item6"></li>    <li class="item7"></li></ul>
Copy after login

ID和类属性

#header

<div id="header"></div>
Copy after login

.title

<div class="title"></div>
Copy after login

form#search.wide

<form id="search" class="wide"></form>
Copy after login

p.class1.class2.class3

<p class="class1 class2 class3"></p>
Copy after login

自定义属性

p[title="Hello world"]

<p title="Hello world"></p>
Copy after login

td[rowspan=2 colspan=3 title]

<td rowspan="2" colspan="3" title=""></td>
Copy after login

[a='value1' b="value2"]

<div a="value1" b="value2"></div>
Copy after login

文本:{}

a{Click me}

<a href="">Click me</a>
Copy after login

p>{Click }+a{here}+{ to continue}

<p>Click <a href="">here</a> to continue</p>
Copy after login

隐式标签

.class

<div class="class"></div>
Copy after login

em>.class

<em><span class="class"></span></em>
Copy after login

ul>.class

<ul>    <li class="class"></li></ul>
Copy after login

table>.row>.col

<table>    <tr class="row">        <td class="col"></td>    </tr></table>
Copy after login

HTML

所有未知的缩写都会转换成标签,例如,foo →

!

<!doctype html><html lang="en"><head>    <meta charset="UTF-8">    <title>Document</title></head><body></body></html>
Copy after login

a

<a href=""></a>
Copy after login

a:link

<a href="http://"></a>
Copy after login

a:mail

<a href="mailto:"></a>
Copy after login

abbr

<abbr title=""></abbr>
Copy after login

acronym

<acronym title=""></acronym>
Copy after login
Copy after login

base

<base href="" />
Copy after login

basefont

<basefont />
Copy after login

br

<br />
Copy after login

frame

<frame />
Copy after login

hr

<hr />
Copy after login

bdo

<bdo dir=""></bdo>
Copy after login

bdo:r

<bdo dir="rtl"></bdo>
Copy after login

bdo:l

<bdo dir="ltr"></bdo>
Copy after login

col

<col />
Copy after login

link

<link rel="stylesheet" href="" />
Copy after login

link:css

<link rel="stylesheet" href="style.css" />
Copy after login

link:print

<link rel="stylesheet" href="print.css" media="print" />
Copy after login

link:favicon

<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
Copy after login

link:touch

<link rel="apple-touch-icon" href="favicon.png" />
Copy after login

link:rss

<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml" />
Copy after login

link:atom

<link rel="alternate" type="application/atom+xml" title="Atom" href="atom.xml" />
Copy after login

meta

<meta />
Copy after login

meta:utf

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
Copy after login

meta:win

<meta http-equiv="Content-Type" content="text/html;charset=windows-1251" />
Copy after login

meta:vp

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
Copy after login

meta:compat

<meta http-equiv="X-UA-Compatible" content="IE=7" />
Copy after login

style

<style></style>
Copy after login

script

<script></script>
Copy after login

script:src

<script src=""></script>
Copy after login

img

<img src="" alt="" />
Copy after login

iframe

<iframe src="" frameborder="0"></iframe>
Copy after login
Copy after login

embed

<embed src="" type="" />
Copy after login
Copy after login

object

<object data="" type=""></object>
Copy after login
Copy after login

param

<param name="" value="" />
Copy after login

map

<map name=""></map>
Copy after login

area

<area shape="" coords="" href="" alt="" />
Copy after login

area:d

<area shape="default" href="" alt="" />
Copy after login

area:c

<area shape="circle" coords="" href="" alt="" />
Copy after login

area:r

<area shape="rect" coords="" href="" alt="" />
Copy after login

area:p

<area shape="poly" coords="" href="" alt="" />
Copy after login

form

<form action=""></form>
Copy after login

form:get

<form action="" method="get"></form>
Copy after login

form:post

<form action="" method="post"></form>
Copy after login

label

<label for=""></label>
Copy after login

input

<input type="text" />
Copy after login

input:text input:t inp

<input type="text" name="" id="" />
Copy after login

input:hidden input:h input[type=hidden name]

<input type="hidden" name="" />
Copy after login

input:search inp[type=search]

<input type="search" name="" id="" />
Copy after login

input:email inp[type=email]

<input type="email" name="" id="" />
Copy after login

input:url inp[type=url]

<input type="url" name="" id="" />
Copy after login

input:password input:p inp[type=password]

<input type="password" name="" id="" />
Copy after login

input:datetime inp[type=datetime]

<input type="datetime" name="" id="" />
Copy after login

input:date inp[type=date]

<input type="date" name="" id="" />
Copy after login

input:datetime-local inp[type=datetime-local]

<input type="datetime-local" name="" id="" />
Copy after login

input:month inp[type=month]

<input type="month" name="" id="" />
Copy after login

input:week inp[type=week]

<input type="week" name="" id="" />
Copy after login

input:time inp[type=time]

<input type="time" name="" id="" />
Copy after login

input:number inp[type=number]

<input type="number" name="" id="" />
Copy after login

input:color inp[type=color]

<input type="color" name="" id="" />
Copy after login

input:checkbox input:c inp[type=checkbox]

<input type="checkbox" name="" id="" />
Copy after login

input:radio input:r inp[type=radio]

<input type="radio" name="" id="" />
Copy after login

input:range inp[type=range]

<input type="range" name="" id="" />
Copy after login

input:file input:f inp[type=file]

<input type="file" name="" id="" />
Copy after login

input:submit input:s

<input type="submit" value="" />
Copy after login

input:image input:i

<input type="image" src="" alt="" />
Copy after login

input:button input:b

<input type="button" value="" />
Copy after login

input:reset input:button[type=reset]

<input type="reset" value="" />
Copy after login

select

<select name="" id=""></select>
Copy after login

option

<option value=""></option>
Copy after login

textarea

<textarea name="" id="" cols="30" rows="10"></textarea>
Copy after login

menu:context menu:c menu[type=context]

<menu type="context"></menu>
Copy after login

menu:toolbar menu:t menu[type=toolbar]

<menu type="toolbar"></menu>
Copy after login

video

<video src=""></video>
Copy after login

audio

<audio src=""></audio>
Copy after login

html:xml

<html xmlns="http://www.w3.org/1999/xhtml"></html>
Copy after login

keygen

<keygen />
Copy after login

command

<command />
Copy after login

bq blockquote

<blockquote></blockquote>
Copy after login

acr acronym

<acronym title=""></acronym>
Copy after login
Copy after login

fig figure

<figure></figure>
Copy after login

figc figcaption

<figcaption></figcaption>
Copy after login

ifr iframe

<iframe src="" frameborder="0"></iframe>
Copy after login
Copy after login

emb embed

<embed src="" type="" />
Copy after login
Copy after login

obj object

<object data="" type=""></object>
Copy after login
Copy after login

src source

<source></source>
Copy after login

cap caption

<caption></caption>
Copy after login

colg colgroup

<colgroup></colgroup>
Copy after login

fst fset fieldset

<fieldset></fieldset>
Copy after login

btn button

<button></button>
Copy after login

btn:b button[type=button]

<button type="button"></button>
Copy after login

btn:r button[type=reset]

<button type="reset"></button>
Copy after login

btn:s button[type=submit]

<button type="submit"></button>
Copy after login

最后

关于更多的HTML以及CSS的缩写请查看:官网文档

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template