uni-app 移动端开发1px像素线条变粗的解决方法

伪类 + scale

	.bor-line{
	  position: relative;
	}
			
	.bor-line:after {
	   content: " ";
	   position: absolute;
	   left: 0;
	   bottom: 0;
	   right: 0;
	   height: 1px;
	   color: #e0e0e0;
	   transform-origin: 0 100%;
	   transform: scaleY(0.5);
	   z-index: 1;
					
	}
	.bor-line:before {
	   content: " ";
	   position: absolute;
	   left: 0;
	   top: 0;
	   right: 0;
	   height: 1px;
	   border-bottom: 1px solid #e0e0e0;
	   color: #e0e0e0;
	   transform-origin: 0 0;
	   transform: scaleY(0.5);
	   z-index: 1;
    }

使用box-shadow模拟边框

//利用css 对阴影处理的方式实现0.5px的效果。
.box-shadow-1px { 
  box-shadow: inset 0px -1px 1px -1px #c8c7cc; 
} 

使用border-image

// 首先需要自己制作一个0.5像素的线条作为线条背景图片
p{ 
    border-width: 0 0 1px 0; 
    border-image: imageUrl 2 0 round; 
} 

利用背景渐变linear-gradient

利用linear-gradient利用背景图片渐变,从有色到透明,默认方向从上到下,从0deg到50%的地方颜色是边框颜色,然后下边一半颜色就是透明了。然后设置背景宽度100%,高度是1px,再去掉repeat,所以有颜色的就是0.5px的边框。代码如下:

.bg_border { 
    background-image: linear-gradient(0deg,black 50%,transparent 50%); 
    background-size: 100% 1px; 
    background-repeat: no-repeat; 
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值