Home Web Front-end HTML Tutorial CSS 简介01_html/css_WEB-ITnose

CSS 简介01_html/css_WEB-ITnose

Jun 24, 2016 am 11:16 AM

一、css组成

选择器{

属性:值;//说明

}

二、分类(三种)

内联式、嵌入式、外部式

内联式:直接把css代码写在现有的html标签中;

嵌入式:可以把css代码写在标签之间,一般将css样式嵌入

标签之间;

外部式:css代码写在一个单独的文件,这个css样式文件以.css为扩展名,在

标签之间通过引入

说明:在相同权值的情况下,内联式>嵌入式>外部式;(就近原则)

三、选择器分类

1.标签选择器:html代码中的标签

2.类选择器:.类选择器{ }

使用class = “类选择器名称”为标签设置一个类

3.id选择器:#选择器{  }

使用id = “ID名称”为一个标签设置

说明:id和class都可以应用任何元素;ID选择器只能在文档中使用一次,类选择器可以使用多次;类选择器可以为一个元素设置多个样式。

4.子选择器:(>),用于选择指定标签元素的第一代子元素

.first > span{color:red;}

5.包含(后代)选择器:加入空格,用于选择指定标签元素下的后辈元素。

.first span{color:red;}

说明:子选择器仅是指他的直接后代(儿子),后代选择器可以作用于所有子后代的元素(儿子,孙子,重孙等);> 作用元素的后一代,空格作用于元素的所有后代。

6.通用选择器:*

它使用*号。能够匹配所有的html标签。

7.分组选择符:,

多个标签元素设置同一个样式时,可以使用分组选择符(,)

h1,span{color:red;}

四、特性

1.继承:css央视具有继承性,继承是一种规则,它允许该样式不仅应用于某个特定的html标签元素,而且应用与它的后代。

2.特殊性:有的时候同一个标签我们给了多个样式,那么元素会采用哪种样式,取决于这个样式的权值,标签的权值为1,类选择符的权值为10,ID选择符的权值最高为100.

3.层叠:如果html文件中某个元素有多个css样式,并且这些css样式具有一样的权重,这个时候就取决于这些css样式的顺序,处于最后面的css会被应用。

4.重要性:!important。采用这种方式说明这个样式权重最高。

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)

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.

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.

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.

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

How to implement adaptive layout of Y-axis position in web annotation? How to implement adaptive layout of Y-axis position in web annotation? Apr 04, 2025 pm 11:30 PM

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

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

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.

How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

See all articles