当前位置:网站首页>Mobile adaptation: vw/vh
Mobile adaptation: vw/vh
2022-07-04 06:41:00 【HHppGo】
vw/vh
The goal is : Able to use vw Company
Set the of web page elements Size
Relative units
relative The size of the viewport
The result of the calculation is
- vw:viewport width
– 1vw =1/100
Viewport width - vh:viewport height
– 1vh =1/100
Viewport height
Code :
<!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> Experience vw and vh</title>
<style> * {
margin: 0; padding: 0; } /* demand : Separate use vw and vh Set the box size vw: Refer to the calculation results of viewport width ,1/100 vh: Reference viewport height calculation results ,1/100 */ .box {
width: 50vw; height: 30vw; background-color: pink; } /* .box { width: 50vh; height: 30vh; background-color: pink; } */ </style>
</head>
<body>
<div class="box"></div>
</body>
</html>
vw
Adaptation principle
The goal is : Realize in Different widths
Of the devices , Page element size Scale proportionally
effect
vw Unit size
- Determine the design draft
Corresponding
Of vw Size (1/100 Viewport width )
– seeDesign width
-> Determine referenceDevice width
( Viewport width )-> determinevw Size
(1/100 Viewport width ) - vw Unit size =
px Unit value / ( 1/100 Viewport width )
vh
Adaptation principle
vh Unit size
- Determine the design draft
Corresponding
Of vh Size (1/100 Viewport height )
– seeDesign width
-> Determine referenceEquipment height
( Viewport height )-> determinevh Size
(1/100 Viewport height ) - vh Unit size =
px Unit value / ( 1/100 Viewport height )
less Code :
// out: ./ * {
margin: 0;
padding: 0;
}
// demand : Separate use vw and vh Set up 68px * 29px The size of your box // The design is viewport width 375px, Viewport height 667px Of // .box {
// width: (68/3.75vw);;
// height: (29/3.75vw);;
// background-color: pink;
// }
.box {
width: (68/6.67vh);;
height: (29/6.67vh);;
background-color: green;
}
// Tips : Choose one of the above two , But at work , Usually use vw, Reference equipment width
vw and vh The mix of ( Can't
)
// out: ./ * {
margin: 0;
padding: 0;
}
// test :vw and vh A mixture of , Set up 68px * 29px Box ( The design draft is 375px Of ) // Design draft 375px * 667px // Tips : In the work ,vw and vh Don't mix , Because when you encounter a full screen, the size of the box will be different from the design .box {
width: (68/3.75vw);
height: (29/6.67vh);
background-color: blue;
}
边栏推荐
猜你喜欢
Can the out of sequence message complete TCP three handshakes
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
27-31. Dependency transitivity, principle
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
C réaliser des jeux de serpents gourmands
2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?
SQL join, left join, right join usage
Variables d'environnement personnalisées uniapp
MySQL learning notes 3 - JDBC
R统计绘图-随机森林分类分析及物种丰度差异检验组合图
随机推荐
MySQL learning notes 3 - JDBC
Can the out of sequence message complete TCP three handshakes
2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
Tar source code analysis Part 7
Overview of convolutional neural network structure optimization
tcp socket 的 recv 如何接收指定长度消息?
P26-P34 third_ template
Google Chrome Portable Google Chrome browser portable version official website download method
Selection (022) - what is the output of the following code?
How does the inner roll break?
tars源码分析之2
tars源码分析之7
C realize Snake games
Arcpy uses the updatelayer function to change the symbol system of the layer
ABCD four sequential execution methods, extended application
Variables d'environnement personnalisées uniapp
Mysql 45讲学习笔记(六)全局锁
1、 Relevant theories and tools of network security penetration testing
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
【问题记录】03 连接MySQL数据库提示:1040 Too many connections