Home Web Front-end HTML Tutorial Peripheral knowledge points_html/css_WEB-ITnose

Peripheral knowledge points_html/css_WEB-ITnose

Jun 24, 2016 am 11:50 AM

em

 1em = the font-size value set by the element itself or inherited from the parent element

1 <h1>left margin = <small>24px</small></h1>2 <h2>left margin = <small>18px</small></h2>3 <p>left margin = <small>12px</small></p>
Copy after login

1 h1{font-size:24px;}2 h2{font-size:18px;}3 p{font-size:12px;}4 h1,h2,p{margin-left:1em;}
Copy after login

font-weight

 The value 100~900 does not have a fixed boldness. It is generally equivalent to a certain deformation name. 400 corresponds to normal, 700 corresponds to bold, and the others depend on the keywords. .

Times hypothetical bold designation

字体 指定关键字 指定数字
TimesRegular normal 100,200,300,400
TimesBold bold 500,600,700,800,900

bolder bold according to the parent element

1 p{font-weight:normal;}/*400,更粗是bold对应700,其中最小值为700*/2 p em{font-weight:bolder;}/*700*/3 4 h1{font-weight:bold;}/*700,更粗假设没有关键字,则设置为下一个更大的数字,最大为900*/5 h1 b{font-weight:bolder;}/*800*/
Copy after login

font-size

No specified number, initial value is medium . Larger is similar to bolder and moves up by the scaling factor based on the parent element, but has no absolute size range (900) limit.

The percentage is also calculated based on the size inherited from the parent element.

These inheritances are level-by-level, and the deeper they are nested, the more they accumulate.

Using px gives a fixed value to the font. This has a hidden danger that users cannot adjust the text size before IE6, so it would be better to use keywords and percentages for the font size.

text-indent

 Text-indent Jin will also inherit.

1 <style type="text/css">2     #demo{text-indent:3%;}3 </style>
Copy after login

1 <div id="demo">2     This is the first line.3     <p>This is the second line while this will also <br>get the text indent style.</p>4 </div>
Copy after login

line-height

 1 <style type="text/css"> 2     body{font-size:10px;line-height:10px;} 3     /*由于大多数浏览器默认font-size最小值为12px,所以此处body设置的字体大小其实为12px*/ 4     5     .paragraphA{line-height:1em;}/*继承字体大小为12px,line-height为12*1=12px*/ 6     .paragraphA p{font-size:18px;}/*line-height为继承的12px*/ 7  8     .paragraphB{line-height:1;}/*使用缩放因子,运用于该元素和所有子元素,各元素根据自己字体大小值计算line-height为12*1=12px*/ 9     .paragraphB p{font-size:14px;}/*自身大小值*缩放因子:line-height为14*1=14px*/10 11     .paragraphC p{font-size:12px;line-height:150%;}/*根据自身指定字体大小计算line-height为12*150%=18px*/12 </style>
Copy after login

1 <div class="paragraphA">2     <p>This is paragraph A which gets a line-height equals 12px.</p>3 </div>4 <div class="paragraphB">5     <p>This is paragraph B which gets a line-height equals 14px.</p>6 </div>7 <div class="paragraphC">8     <p>This is paragraph C which gets a line-height equals 18px.</p>9 </div> 
Copy after login

vertical-align

The default value is baseline, aligned with the text baseline (letters such as "g", The small tail is below the baseline).

Text-bottom: Align with the bottom line of the text (the "bottom tangent line" of the text, the tangent line at the bottom of the small tail).

Bottom: Align the bottom of the line box (when the line height is greater than the font size, there is a certain distance below the small tail at the bottom of the space occupied by the line height).

The percentage is to increase or decrease the specified amount relative to the baseline (row height) of the parent element.

px: Positive values ​​will increase, negative values ​​will decrease.

Note that vertical-align can only be used for inline elements or table cell elements.

References

"Css Definitive Guide" Chapter 4~6

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.

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

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

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

See all articles