search
HomeWeb Front-endHTML Tutorial前端必备快速编码工具_html/css_WEB-ITnose

最受大家喜欢的一个快速编码的工具就是Emmet (Zen Coding),这是一种一种新的使用仿CSS选择器的语法来快速开发HTML和CSS的方法。

也许对于我们这些菜鸟级别的程序员来说,脚踏实地的一字字的打代码才是正确的选择。但是,学会快速的把整个框架和重复代码用最快的速度码出来,这个对每个程序员来说都是很有必要的,而且在工程上还能大大的缩减开发时间。

声明:这里只和大家说最常用的也够你使用的形式,具体的可参考官方文档 ZenCodingCheatSheet.pdf

1、创建模板

开始编码的时候,我们需要一个模板,我们以html5为例。

html:5

几个字符,敲一下 Tab 键就搞定了,生成的模板如下:

<!DOCTYPE HTML><html lang="en-US"><head>    <meta charset="UTF-8">    <title></title></head><body></body></html>

这里要说明一下,不是所有的编辑器都敲Tab 键,有的是 Ctrl + E 或 Ctrl + J,这要看你的编辑器是什么而定。

2.css 和 js 导入

导入css
link:css
<link rel="stylesheet" type="text/css" href="style.css" media="all">
导入js
script:src
<script type="text/javascript" src=""></script>

3.开始装逼之旅

开始之前先来熟知一下下面的这些语法:

  • E元素名(div、p);
  • E#id带Id的元素(div#content、p#intro、span#error);
  • E.class带class的的元素(div.header、p.error),id和class可以连着写,div#content.column
  • E>N子元素(div>p、div#footer>p>span)
  • E*N多项元素(ul#nav>li*5>a)
  • E+N多项元素E$*N带序号的元素
以上的语法够你用的了,光说不练嘴把戏,看代码吧!

元素名最简单,其实就是为你创建一个该名称的标签,有的成双成对,有的就只能是单身狗,o(^▽^)o

div  或 input
<div></div> 或 <input type="">
创建带id的元素
div#divid
<div id="divid"></div>
创建带class的元素
div.divclass
<div class="divclass"></div>
带一个儿子
div.divclass>p
<div class="divclass">    <p></p></div>
带一个兄弟
div.divclass>p+span
<div class="divclass">    <p></p>    <span></span></div>
带多个儿子和多个兄弟
div.divclass>p*3+span*2
<div class="divclass">    <p></p>    <p></p>    <p></p>    <span></span>    <span></span></div>
给儿子们取名字和给兄弟不同称呼
div.divclass>p#son$*3+span.brother$*2
<div class="divclass">    <p id="son1"></p>    <p id="son2"></p>    <p id="son3"></p>    <span class="brother1"></span>    <span class="brother2"></span></div>

是不是很神奇,现在来给来个小小的栗子吃,我们用这种方式创建一个导航的简单架构:

div#header>img.logo+ul#nav>li*4>a

见证奇迹的时刻

<div id="header">    <img src="" alt="" class="logo">    <ul id="nav">        <li><a href=""></a></li>        <li><a href=""></a></li>        <li><a href=""></a></li>        <li><a href=""></a></li>    </ul></div>

他是怎么实现的呢?这些实现的主要是在一个叫 Zen Coding.js 的文件里面,快捷键方式也是里面决定的。

如果觉得没事的话,自己可以去看看!

细心的朋友应该发现了什么吧,不是说有快速开发CSS的方法么,怎么只有HTML的方法,哈哈,那个太多了!不过小编这边还是大概的和大家总结一下,想要更加详细的内容,可以看看上面提供的官方文档。

4.CSS登场

特殊单词的缩写,除下面外,其它的都用首写字母。
单词 缩写 单词 缩写
position pos float fl
compact cp clip cp
overflow ov marquee mq
zoom zoo table tb
box bx shadow sh
max ma min mi
border bd collapse cl
background bg break bk
background-size bgz avoid av
list-style lis content ct
counter co white wh
word wo emphasize em
smooth sm stretch st
resize rz cursor cur
page pg window wid
radius rz orphans orp

好像很多啊,不过这些能用到的也不是很多,不要紧张,最常用到的也就那几个标上粗体的。

这里为大家演示几个栗子:

pos:s          --->   position:static;fl:r           --->   float:right;ov:h           --->   overflow:hidden;bxz:bb         --->   box-sizing:border-box;bxsh:n         --->   box-shadow:none;whs:nw         --->   white-space:nowrap;cur:p          --->   cursor:pointer;bg:n           --->   background:none;... ...

大家在看官方文档的时候,还会看到一种是用加号(+)的,这个主要是用来做后面有多个参数使用的,但是那也只是提示,不是让你跟着写上去用,如果你写上去了,那就变成这样子:

bxsh+           --->   <bxsh+></bxsh+>这是什么鬼????正确的应该是:bxsh            --->   box-shadow:;

有前缀的要怎么写呢?

-webkit- 的缩写 w-moz- 的缩写 m

再来给栗子:

bdi:m           --->   -moz-border-image:url() 0 0 0 0 stretch stretch;bdi:w           --->   -webkit-border-image:url() 0 0 0 0 stretch stretch;
好了,写的也差不多了。如果学到的话,就来点赞吧!^_^
Statement
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
The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.