当前位置:网站首页>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/100Viewport width - vh:viewport height
– 1vh =1/100Viewport 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
CorrespondingOf 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
CorrespondingOf 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;
}
边栏推荐
- 2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
- tars源码分析之2
- 同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
- Analysis of tars source code 1
- [backpack DP] backpack problem
- 《国民经济行业分类GB/T 4754—2017》官网下载地址
- What is the "relative dilemma" in cognitive fallacy?
- [problem record] 03 connect to MySQL database prompt: 1040 too many connections
- How to help others effectively
- Inputstream/outputstream (input and output of file)
猜你喜欢

R统计绘图-随机森林分类分析及物种丰度差异检验组合图

Variables d'environnement personnalisées uniapp

C realize Snake games

Reading notes of Clickhouse principle analysis and Application Practice (4)

Learning multi-level structural information for small organ segmentation

响应式移动Web测试题

uniapp 自定义环境变量

GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式

SQL join, left join, right join usage

Mysql 45讲学习笔记(七)行锁
随机推荐
Reading notes of Clickhouse principle analysis and Application Practice (4)
C realize Snake games
selenium IDE插件下载安装使用教程
2022, peut - être la meilleure année économique de la prochaine décennie, avez - vous obtenu votre diplôme en 2022? Comment est - ce prévu après la remise des diplômes?
金盾视频播放器拦截的软件关键词和进程信息
Realize IIC data / instruction interaction with micro batg135
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
Modify TCP timestamp to optimize transmission performance
Native Cloud - SSH articles must be read on Cloud (used for Remote Login to Cloud Server)
Mysql 45讲学习笔记(十)force index
Tar source code analysis Part 2
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
Sleep quality today 78 points
11. Dimitt's law
The width of the picture in rich text used by wechat applet exceeds the problem
[number theory] fast power (Euler power)
2022年,或许是未来10年经济最好的一年,2022年你毕业了吗?毕业后是怎么计划的?
tars源码分析之6
Download address of the official website of national economic industry classification gb/t 4754-2017
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!