当前位置:网站首页>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;
}
边栏推荐
- CORS is not intended to protect API endpoints - nikofischer
- STM32 单片机ADC 电压计算
- C實現貪吃蛇小遊戲
- Which water in the environment needs water quality monitoring
- [problem record] 03 connect to MySQL database prompt: 1040 too many connections
- The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
- Tar source code analysis Part 10
- Mysql 45讲学习笔记(十二)MySQL会“抖”一下
- tars源码分析之3
- R统计绘图-随机森林分类分析及物种丰度差异检验组合图
猜你喜欢

Shopping malls, storerooms, flat display, user-defined maps can also be played like this!

How to use multithreading to export excel under massive data? Source code attached!

期末周,我裂开

雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)

P26-P34 third_ template

C réaliser des jeux de serpents gourmands
![[March 3, 2019] MAC starts redis](/img/ff/88638fcdc8d24dc268781c224e8195.jpg)
[March 3, 2019] MAC starts redis

Inputstream/outputstream (input and output of file)

Cloud native - SSH article that must be read on the cloud (commonly used for remote login to ECS)

R statistical mapping - random forest classification analysis and species abundance difference test combination diagram
随机推荐
由于dms升级为了新版,我之前的sql在老版本的dms中,这种情况下,如何找回我之前的sql呢?
【FPGA教程案例8】基于verilog的分频器设计与实现
tars源码分析之2
Mysql 45讲学习笔记(十二)MySQL会“抖”一下
Arcpy 利用updatelayer函数改变图层的符号系统
Fundamentals of SQL database operation
Tar source code analysis Part 10
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
Operator < <> > fool test case
Mysql 45讲学习笔记(六)全局锁
[number theory] fast power (Euler power)
tars源码分析之5
How does the recv of TCP socket receive messages of specified length?
MySQL 45 lecture learning notes (VII) line lock
Tree DP
js 常用时间处理函数
双色球案例
P26-P34 third_ template
Background and current situation of domestic CDN acceleration
C réaliser des jeux de serpents gourmands