1 使用meta标签
使用viewport标签,将其中content的width定义为设计图的尺寸宽度,然后在直接使用
1px即可(不同屏幕宽度会自动进行缩放)
<meta name="viewport" content="width=750, user-scalable=no">
2 使用box-shadow的方法
可以通过这样设定
box-shadow: 0 0 0 0.5px black;
3 ::after定位伪类实现的答案
<style>
div {
position: relative;
box-sizing: border-box;
background-color: blueviolet;
width: 200px;
height: 200px;
margin-top: 10px;
/* box-shadow: 0px 0px 0px 0.5px green; */
}
div::after {
position: absolute;
content: "";
background-color: red;
width: 100%;
height: 0.5px;
bottom: 0px;
}
</style>
</head>
<body>
<div></div>
4 transform 缩放实现
<style>
div {
position: relative;
box-sizing: border-box;
background-color: blueviolet;
width: 200px;
height: 200px;
margin-top: 10px;
/* box-shadow: 0px 0px 0px 0.5px green; */
}
div::after {
position: absolute;
content: "";
width: 200%;
height: 200%;
border: 1px solid red;
transform-origin: 0 0;
transform: scale(0.5);
}
</style>
</head>
<body>
<div></div>
</body>
标签:box,px,0.5,width,0px,border From: https://www.cnblogs.com/ranyonsue/p/17236067.html