移动端H5页面中1px边框的解决办法

在移动端web开发中,UI设计稿中设置边框为1像素,前端在开发过程中如果出现border:1px,测试会发现在某些机型上,1px会比较粗,即是较经典的 移动端1px像素问题。

简书中描述很好的文章,细节可以点击进去看,如果直接想看代码实现,请看下面

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, width=device-width">
		<title>移动端1px边框问题</title>
		<style>
			* {
				margin: 0;
				padding: 0;
			}

			ul,
			li {
				list-style: none;
			}

			.lines {
				width: 200px;
				margin: 0 auto;
			}

			.lines li {
				border: 1px solid #cccccc;
				height: 50px;
				line-height: 50px;
				text-align: center;
				border-radius: 13px;
				margin-top: 10px;
			}

			.hairlines {
				width: 200px;
				margin: 0 auto;
				border-radius: 3px;
			}

			.hairlines li {
				height: 50px;
				line-height: 50px;
				border: none;
				text-align: center;
				position: relative;
				margin-top: 10px;
			}

			.hairlines li:after {
				content: '';
				position: absolute;
				left: 0;
				top: 0;
				border: 1px solid #cccccc;
				border-radius: 26px;
				width: 200%;
				height: 200%;
				transform: scale(0.5);
				transform-origin: left top
			}
		</style>
	</head>
	<body>
		粗线
		<ul class="lines">
			<li>1</li>
			<li>2</li>
		</ul>
		细线
		<ul class="hairlines">
			<li>3</li>
			<li>4</li>
		</ul>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值