Blogger Information
Blog 7
fans 0
comment 0
visits 3575
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
常用布局单位
༻娇ღ娇༺
Original
428 people have browsed it

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>常用布局单位</title>
</head>
<body>
<div class="box"></div>
<!-- 常用布局单位:px, em, rem , vh, vw -->
<!-- 绝对单位: px , 1in = 96px 相对单位: em,rem, vh, vw -->
<style>
{
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
font-size: 10px;
}
.box {
font-size: 20px-;
/
font-size: 字号大小, 它是一个可以被继承的属性 /
width: 15em-;
height: 300px-;
/
此时盒子的宽度:300px,em: 永远和当前或父级的font-size进行绑定,因为em是随着当前的字体发生变化,此时1em=20px,即15em就等于300px /
background-color: bisque-;
}
.box {
font-size: 20px;
width: 15rem;
height: 300px;
/
此时盒子的宽度:150px,rem: 永远和html(根元素)中的font-size绑定此时1em=10px,即15em就等于150px /
background-color: pink;
}
/
vh, vw /

/
vw: 将视口宽度分为100份, 1vw = 1/100 /
/
vh: 将视口高宽分为100份, 1vh = 1/100 */
</style>
</body>
</html>

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post