CSS基础知识笔记(三)_html/css_WEB-ITnose
继承
继承是一种规则,它允许样式不仅应用于某个特定html标签元素,而且应用于其后代。比如下面代码:如某种颜色应用于p标签,这个颜色设置不仅应用p标签,还应用于p标签中的所有子元素文本,这里子元素为span标签。
CSS中存在一些不能继承的样式,如:
border:1px solid red;
特殊性
同一标签设置不同的css样式,游览器根据标签权值来判断使用哪个CSS样式。
标签的权值为1,类选择符的权值为10,ID选择符的权值最高为100。
继承也有权值且为最低。
p{color:red;} /*权值为1*/p span{color:green;} /*权值为1+1=2*/.warning{color:white;} /*权值为10*/p span.warning{color:purple;} /*权值为1+1+10=12*/#footer .note p{color:yellow;} /*权值为100+10+1=111*/
层叠
含义:在HTML文件中对于同一个元素可以有多个CSS样式存在,当有相同权重的样式存在时,会根据这些css样式的前后顺序来决定处在最后面的样式会被应用。
样式优先级:内联样式表(标签内部)> 嵌入样式表(当前文件中)> 外部样式表(外部文件中)。
重要性
特殊情况下将某些样式提升到最高权值,需要用如下代码来解决:
p{color:red!important;}
!important必须写在分号的前面
样式优先级:
游览器默认样式<网页制作者样式<用户设置样式
文字排版-字体、字号、颜色
通用字体:微软雅黑
body{font-family:"Microsoft Yahei";} /*兼容性更好*/body{font-family:"微软雅黑";}
body{font-size:12px;color:#666}
文字排版-粗体、斜体、下划线
粗体:span{font-weight:bold;}斜体:a{font-style:italic;}下划线:span{text-decoration:underline;}text-decoration指的是:文本的装饰,属性值有none默认不显示下划线.none: 指定文字无装饰underline: 指定文字的装饰是下划线overline: 指定文字的装饰是上划线line-through: 指定文字的装饰是贯穿线blink: 指定文字的装饰是闪烁。
文字排版-删除线、缩进、行间距(行高)
删除线:.oldPrice{text-decoration:line-through;}为文字加删除线缩进:p{text-indent:2em;} 2em的意思就是文字的2倍大小。行间距:p{line-height:1.5em;} 设置段落行间距1.5倍
段落排版-中文字间距、字母间距、对齐
中文字、字母间距:
p{letter-spacing:50px;}(中文字和字母间距)p{word-spacing:50px;}(字母和字母间距)对齐:p{text-align:center;} 居中p{text-align:left;} 居左p{text-align:right;} 居右

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

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

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











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.

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

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.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

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...

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.

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 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.
