HTML移动端单位

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<style type="text/css">
		*{
			margin: 0px;
			padding: 0px;
		}
		#top{
			position: absolute;
			top:0;
			height: 20%;
			background: blue;
			text-align: center;
			width: 100%;
			color:#FFf;
			font-size: 5em;  
		}
		#bottom{
			position: fixed;
			bottom:0;
			height: 20%;
			background: blue;
			text-align: center;
			width: 100%;
			color:#FFf;
		}
	</style>
	<body>
		<!--在很久以前使用em/百分比
		后来又发现了一个新单位rem/vw;vh-->
		<div id="top">顶部导航条</div>
		<div id="body">
			使用em为单位,会根据父元素的字体大小为参考,比如父元素字体大小为12px,1em=12px;
			使用rem为单位,会根据html根元素的字体大小为参考。
			使用vw,vh作为单位是以当前屏幕视口为参考,
			1vw=宽度的1%
		</div>
		<div id="bottom">底部选项卡</div>
		
	</body>
</html>

 

posted @   JackieDYH  阅读(24)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示