当前位置:网站首页>flex/fixed上中下(移动端)
flex/fixed上中下(移动端)
2022-06-12 05:33:00 【昔冰_G】
方案一:不使用fixed
html{
height:100vh;
/* 如果这里不给100%,那就会认为自动,那底部栏就跑到最下面了(视口外) */
font-size:26.667vw;
/*
100vw=375px 1px=0.26667vw
为方便计算所以设定font-size为100px,也就是26.667vw
为了实现跟随屏幕改变,所以这里用的vw基准,而不是固定的px
*/
}
body{
width:100%;
height:100%;
/* 如果这里不给100%(父高100%),那就会认为自动,那底部栏就跑到最下面了(视口外) */
display: flex;
font-size: 0.16rem;
flex-direction: column;
}
header{
height:.67rem;
/* 测得67px就是 67/(html的font-size)=67/100=0.67rem */
}
main{
flex:1;
overflow:auto;
}
footer{
height:.5rem;
}方案二:使用fixed
html{
height:100vh;
/* 如果这里不给100%,那就会认为自动,那底部栏就跑到最下面了(视口外) */
font-size:26.667vw;
/*
100vw=375px 1px=0.26667vw
为方便计算所以设定font-size为100px,也就是26.667vw
为了实现跟随屏幕改变,所以这里用的vw基准,而不是固定的px
*/
}
body{
width:100%;
height:100%;
/* 如果这里不给100%(父高100%),那就会认为自动,那底部栏就跑到最下面了(视口外) */
font-size: 0.16rem;
}
header{
height:.67rem;
/* 测得67px就是 67/(html的font-size)=67/100=0.67rem */
positon:fixed;
left:0;
bottom:0;
}
main{
overflow:auto;
padding-top:0.67rem;
/* 由于header固定了,脱离文档流,所以这里往下挤一下才能显示main的原被header遮掩的部分内容 */
padding-bottom:.5rem;
/* 对应footer的高度,避免被底部遮掩,向上挤一下 */
}
footer{
height:.5rem;
positon:fixed;
left:0;
bottom:0;
}边栏推荐
- 31. stack push in and pop-up sequence
- CODIS stress test (PHP)
- WiFi band resources
- Multi thread learning v. volatile visibility and cache inconsistency, instruction reordering
- What is thinking
- About architecture (in no particular order)
- Lldp protocol
- Calculation method notes for personal use
- Halcon 用点来拟合平面
- 19. regular expression matching
猜你喜欢

Performance test - performance test tool analysis

Detailed usage of vim editor

ESP8266 Arduino OLED

个体工商户是不是法人企业

Codis 3. X expansion and contraction

CODIS long link test

Selenium crawler automatically captures TOEFL test position of NEEA website

Vivado HLS introductory notes

深入理解异步编程

Test work summary - performance test indicators
随机推荐
Go 接口实现原理【高阶篇】
20. string representing numeric value
UBI details and JFFS2 square FS UBIFS
Servlet core technology
Towards End-to-End Lane Detection: an Instance SegmentationApproach
Optipng can optimize the compressed PNG picture file format
16. 最接近的三数之和
虚函数与纯虚函数的关系
利用jieba库进行词频统计
How does WiFi 802.11 correspond to 802.3
Some optimization methods for UI Application of Qt5 on Hisilicon security platform
Development of video preview for main interface of pupanvr-ui
Tkinter uses webview2 web component (sequel)
国企为什么要上市
59 - II. Maximum value of the queue
37. serialized binary tree
Detailed usage of vim editor
Project requirements specification
Main business objects of pupanvr record (5)
Go 面向接口编程实战