Home Web Front-end HTML Tutorial 第 30 章 使用 Emmet 插件_html/css_WEB-ITnose

第 30 章 使用 Emmet 插件_html/css_WEB-ITnose

Jun 24, 2016 am 11:19 AM

学习要点:

1.安装方式

2.自定义!生成

3.快速生成

 

主讲教师:李炎恢

 

本章主要探讨了解一下 Sublime Text3 的一个 HTML5 代码提示插件:Emmet,这个插件比自带原生的要强大许多。

 

一.安装方式

Emmet 插件安装一般采用两种方式,1.通过命令安装;2.下载离线安装。我这里直接采用的是下载离线安装方式。具体步骤:

1.解压下载好的 Emmet 插件包(这里会提供);

2.将 Emmet 和 PyV8 两个文件夹复制到 Sublime Text3 的程序包中;

3.左下角会显示自动安装,安装好后,重启 Sublime Text3;4.在编辑器输入英文状态下的“!”,然后 ctrl+e,出现了 HTML5 的代码库,则安装

成功。

注:如果安装失败或出现其他错误,请自行百度选用其他方式安装,或解决安装出错的问题。

 

二.自定义!生成

我们输入!,然后 ctrl+e,默认情况下会出现如下代码:

//默认代码

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

  这里有两个地方和我们之前生成的代码不一样,第一处是:doctype 没有大写;第二处:lang 是 en 的。其实这两处不改也没有太大关系,但有强迫症的看了可能会难受。具体修改方法如下:

1.首先,进入程序包 pagkages;

2.其次,进入 Emmet 文件夹,再进入 emmet 文件夹,找到 snippets.json 文件;

3.最后,打开这个文件,找到相应处修改即可。

三.快速生成

  Emmet 提供了非常丰富的 HTML 和 CSS 代码的快速生成功能,通过使用快速生成代码,极大的增加了开发速度。只不过,Emmet 提供的生成方式需要二次学习,起初可能还不如手工敲击的快。所以,需要一定时间的学习磨合。

//快速生成 HTML5 代码结构

! + (ctrl + e 或 tab 键) 或 html:5 + tab 键

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

所有代码生成,都需要通过 tab 键来生成代码,后面不在赘述。

//快速生成标签代码 a

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

//快速生成标签相应的属性值a:link、a:mail

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

//生成标签内的值a{超链接}

<a href="">超链接</a>
Copy after login

//生成 CSS 链接 link link

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

//生成表单控件input、input:hidden

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

//生成带子标签的一组标签ul+、ol+、dl+、table+

<ul>    <li></li></ul><ol>    <li></li></ol><dl>    <dt></dt>    <dd></dd></dl><table>    <tr>        <td></td>    </tr></table>
Copy after login

//生成嵌套子标签 nav>ul>li

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

//生成相邻兄弟标签 div+p+h1

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

//生成乘积数量的标签 ul>li*5

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

//创建具有 ID 的标签 div#header

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

//创建具有 class 的标签 div.header、div.header.sidebar

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

 

以上是 HTML 部分的代码生成功能,下面来看下 CSS 的快速生成功能:

//生成 position: relative pos

输入 pos 即可出现 position:relative 这组 CSS 样式,并且 relative 是选定状态,有助于你更换属性值。

但是我们发现使用 sublime 结合 Emmet 插件的 CSS 提示非常的灵活,不会死板的必须要输入 pos。下面的输入都可以得到相应的值:

po = position: relative

只要输入 po 或者大于 po 字母量的值,都可以得到 position:relative。当然,如果你只是输入 p,那么由于优先级的考虑,出现的是 padding: |。

如果你输入有误,它也会自动纠错,比如下面这个:

pod = position: relative

如果你想一开始得到的是 absolute 这个属性值,那么直接输入:

poa = position: absolute;

当然,上门的标准写法是这样的:

pos:a = position: absolute;

如果想输入背景的属性,直接使用 bg 即可:

bg = background: |;

使用 bg+可以展开背景属性的完整形式: bg+ = background: #fff url() 0 0 no-repeat;

使用 bg:n 可以设置背景属性值为 none: bg:n = background: none;

备注:HTML 和 CSS 其他大部分代码生成方案,可以参考如下网址:

http://docs.emmet.io/cheat-sheet/

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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

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

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

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 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 Design The Future of HTML: Evolution and Trends in Web Design Apr 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 Overview HTML vs. CSS vs. JavaScript: A Comparative Overview Apr 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.

The Future of HTML, CSS, and JavaScript: Web Development Trends The Future of HTML, CSS, and JavaScript: Web Development Trends Apr 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.

See all articles