第一种:viewport的meta标签
使用html的meta
标签,在viewport
类型内容写上initial-scale=0.5, maxinum-scale=0.5, mininum-scale=0.5
,此时,在移动端的1px就等于0.5了
缺点:
- 只针对移动端,在PC端不生效;
第二种:使用transform:scale
使用css样式,transform: scale(0.5, 0.5);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 第一种,viewport只针对移动端,只能在移动端上看到效果,1px就等于为0.5px -->
<meta name="viewport" content="width=device-width, initial-scale=0.5, maxinum-scale=0.5, mininum-scale=0.5">
<title>画一条0.5px的线</title>
<style>
.half-px {
/* 第二种,使用transform:scale */
transform: scale(0.5, 0.5);
border-bottom: 1px solid red;
}
</style>
</head>
<body>
<div class="half-px"></div>
</body>
</html>
参考:https://blog.csdn.net/qq_42068550/article/details/101162325
网友评论