当前位置:网站首页>1px問題
1px問題
2022-06-10 02:52:00 【Float544】
物理像素:顯示器上的真實像素,每個像素的大小是屏幕固有的屬性。設備分辨率描述的就是這個顯示器的寬和高是多少個設備像素。例如:1920*1080。
設備獨立像素:操作系統定義的像素單比特。操作系統將設備獨立像素轉化為設備像素,從而控制屏幕上真正的物理像素點。CSS屬於設備獨立像素。
設備像素比 = 物理像素 / 設備獨立像素
dpr = 1 一個物理像素顯示一個設備獨立像素
dpr = 2 四個物理像素顯示一個設備獨立像素
出現移動端1px問題主要是因為設備像素比不為1導致的。在pc上dpr = 1。但在移動設備中基本dpr不為1,這也就導致了在移動端上1px展示的看起來比較粗。
解决方案:
transform + 偽類
dpr = 2 50%
dpr = 3 33.3%
transform:scaleY(0.5)
transform-origin:50% 0;
<style>
div{
height: 150px;
width: 150px;
background-color: pink;
margin: auto;
}
div:after{
content: '';
display: block;
width: 100%;
background-color: black;
height: 10px;
transform: scaleY(0.5);
transform-origin:50% 0;
}
</style>
</head>
<body>
<div></div>
</body>
第二種方法:
box-shadow
边栏推荐
- Ones Fengbin: from engineer to CTO, with uncertainty and incomplete information | ones talk
- MySQL 8.0.28 installation and configuration tutorial
- Should a reliable and safe company open an account for US crude oil futures?
- Arduino and processing serial port communication (match function)
- Double pointer | 844 Compare strings with backspace
- Mysql database user permission management
- Detailed explanation of redis iterative query and its use: scan command, sscan command, hscan command and zscan command
- MySQL 8.0.29 installation and configuration method graphic tutorial (Windows zip version)
- 时间戳 变换为 标准时间格式
- Drawing of common charts
猜你喜欢
The process of manually installing redis extensions in yii2 framework

Obtain the name of the province or city 【 project mall 】

promise 介绍和实现

pandas连接数据库读写文件

21.动态规划整理

How to do enterprise digital transformation? Three fusions and three transformations

C # extension method (this in the method parameter)

midway的使用教程

51單片機入門——紅外通信

重磅!DIY的Prometheus主备方案,全网唯一。生产未上,测试先行。
随机推荐
DataFrame日期数据处理
^27 timer related problems
Should a reliable and safe company open an account for US crude oil futures?
51單片機入門——紅外通信
Taobao applet 2048 games
Internal resources of stm32
双指针 | 977. 有序数组的平方
Obtain the name of the province or city 【 project mall 】
TS 38.304
Vscode c语言代码Ctrl+左键无法转跳到定义
uni-app 移动端本地储存数据库sqlite,无存储限制
新增收货地址【项目 商城】
常见图表的绘制
51单片机入门——步进电机
flutter 双端扫码下载app
在子集合中第一个元素是由另一个数组插入的
Li Kou daily question - day 17 -349 Intersection of two data
Add receiving address [project mall]
JDBC introductory exercise, is it caused by the version? What does this error mean?
Detailed explanation of redis iterative query and its use: scan command, sscan command, hscan command and zscan command