当前位置:网站首页>A practical scheme of realizing 0.5px on mobile terminal
A practical scheme of realizing 0.5px on mobile terminal
2022-07-24 18:12:00 【Solution without encirclement】
We know , Theoretically px The smallest unit of is 1, But in setting px When the value of , Set up directly 0.5px There are great differences between different browsers , And we can see that different browsers of different systems have different effects on the decimal point px There are different treatments .Chrome Will be able to 0.5px Rounding becomes 1px, The less than 0.5px As 0,Firefox Will not be less than 0.55px As a 1px,Safari Is not less than 0.75px As a 1px. So the following summarizes the implementation 0.5px How to implement .
programme 1: Pseudo elements +scale ( Best compatibility , recommend )
Realization way : Set pseudo elements for containers , Set absolute positioning , Width and height are 200%, The border is 1px, And then use transform:scale(0.5) Let pseudo elements shrink by half , At this time, the border of the pseudo element coincides with the edge of the container .
programme 2: Pseudo elements + background ( Suitable for setting a border , There is no way to show rounded corners )
Realization way : Set pseudo elements for containers , Set absolute positioning , Height 1px, Set linear gradient for background image , Half colored, half transparent , Visually only 0.5px.
programme 3: Use shadows instead of borders
characteristic : convenient , Can display rounded corners normally , And it can be achieved 0.1px Wait for a thinner border , Compatibility is OK .
Code implementation
<style>
.box {
width: 360px;
height: 50px;
border-radius: 5px;
margin-top: 20px;
line-height: 50px;
}
/* Set up directly border-width */
.box-normal {
border: 0.5px solid red;
}
/* programme 1: Pseudo elements +scale */
.box1 {
position: relative;
}
.box1::after {
position: absolute;
bottom: 0;
z-index: -边栏推荐
- 0625~<config>-<bus>
- 关于接口的写法 1链式判读 ?. 2方法执行 (finally)一定会执行
- Three ways of redis cluster
- 阿里巴巴1688按关键字搜索商品 API 使用展示
- 阿里巴巴/1688按图搜索商品(拍立淘) API使用说明
- Brats18 - Multimodal MR image brain tumor segmentation challenge continued
- 0614~ holiday self study
- Alibaba /1688 API instructions for searching products by map (pailitao)
- T245982 「KDOI-01」醉花阴
- Shanghai Jiaotong University team used joint deep learning to optimize metabonomics research
猜你喜欢

How does win11 enhance the microphone? Win11 enhanced microphone settings

Stream, file, IO

How to render millions of 2D objects smoothly with webgpu?

Go language file operation

In depth analysis of the famous Alibaba cloud log4j vulnerability

PXE高效批量网络装机

The drop-down list component uses iscrol JS to achieve the rolling effect of the pit encountered

C language to achieve a static version of the address book

如何用WebGPU流畅渲染百万级2D物体?

Definition and storage of adjacency table and adjacency storage of directed graph and undirected graph
随机推荐
深入解析著名的阿里云Log4j 漏洞
Wu Enda writes: how to establish projects to adapt to AI career
JMeter -- silent operation
jmeter -- prometheus+grafana服务器性能可视化
猜JWT关键字
How to follow the "low coupling" design principle?
【obs】视频、音频编码与rtmp发送的配合
Section 9 cache penetration follow Daewoo redis ------- directory posts
0613~自习
模拟实现vector
【obs】依赖库: x264 vs 构建
Use of jumpserver
运维小白成长记——架构第8周
移动端实现0.5px的实用方案
How to prepare for hyperinflation
The drop-down list component uses iscrol JS to achieve the rolling effect of the pit encountered
0629 ~ SaaS platform design ~ global exception handling
Just one dependency to give swagger a new skin, which is simple and cool!
T245982 「KDOI-01」醉花阴
0613 ~ self study