Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CSS unit of length how to use em

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to use CSS length unit em". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

First, why use em

Em is also a unit of css, similar to px. Many people will wonder why they still use em when they have px, and em is more troublesome to use than px.

Em is mainly used for flexible layout. Here is a small chestnut to illustrate the power of em.

Document

* {

Margin:0

Padding:0

}

Ul {

List-style:none

}

.top {

Height:80px

Background-color:black

}

.main {

Width:960px

Background-color:#ccc

Margin:0auto

Overflow:hidden

}

.left {

Width:30%

Height:100%

Background-color:aqua

Border:1pxsolidred

Float:left

Font-size:16px

Line-height:18px

}

.right {

Width:60%

Height:100%

Font-size:1em

Line-height:1.125em

Background-color:deeppink

Border:1pxsolidred

Float:right

}

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test case, without em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

Em test cases have the power of em

This imitates the general layout of a web page and gives the difference between using em and px.

This is the end of the content of "how to use CSS length unit em". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report