CSS实现0.5px的边框的两种方式

方式一

<style>
.border {
	width: 200px;
	height: 200px;
	position: relative;
}
.border::before {
  content: "";
  position: absolute;
  left:0;
  top: 0;
  width: 200%;
  height: 200%;
  border: 1px solid blue;
  transform-origin: 0  0;
  transform: scale(0.5);
}
</style>

<div class="border"></div>

方式二

<style>
.border {
	width: 200px;
	height: 200px;
	position: relative;
}
.border::before {
	position: absolute;
    box-sizing: border-box;
    content: " ";
    pointer-events: none;
	top: -50%;
    right: -50%;
    bottom: -50%;
    left: -50%;
    border: 1px solid blue;
    transform: scale(0.5);
}
</style>

<div class="border"></div>
全部评论

相关推荐

2025-12-22 15:04
江西农业大学 Web前端
SaviorSu:直接说下学期可以请假,一般情况学校允许我26届,大三就直接去实习了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务