1.transform:scale(0.5)
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.half-px{/*height为0.5px的直线时,浏览器会四舍五入为1px的直线 */
background-color: aqua;
height: 0.5px;
}
.half-px1{
background-color: aqua;
height: 1px;
transform: scale(0.5);/*使用缩放功能将直线缩放0.5倍*/
}
</style>
</head>
<body>
<div style="width: 20px; height: 20px;"></div>
<div class="half-px"></div>
<div style="width: 200px; height: 20px;"></div>
<div class="half-px1"></div>
</body>
</html>
2.meta viewport的方式
<meta name="viewport" content="width=device-width,initial-sacle=0.5">
//只有在移动端才能看到效果
3.canvas
<body>
<canvas id="drawing" width=" 200" height="200">A drawing of something.</canvas>
<script>
var drawing = document.getElementById("drawing");
if(drawing.getContext){
var context = drawing.getContext("2d");
context.lineWidth = 0.5;
context.beginPath();
context.moveTo(30, 30);
context.lineTo(200, 100);
context.stroke();
}
</script>
</body>
4.SVG
<svg id="svgLineTutorial" height="200px" width="200px" xmlns="http://www.w3.org/2000/svg">
<line x1="50" y1="50" x2="200" y2="200" style="stroke:Green;stroke-width:0.5"/>
</svg>
<svg id="svgLineTutorial" height="200px" width="200px" xmlns="http://www.w3.org/2000/svg">
<line x1="50" y1="50" x2="200" y2="200" style="stroke:Green;stroke-width:1"/>
</svg>
5.设置box-shadow
.d2 {
width: 100px;
height: 100px;
background-color: yellowgreen;
box-shadow: 0 0.5px grey;
}
6.设置border
.d1 {
width: 100px;
height: 100px;
background-color: yellow;
border-bottom: 0.5px solid black;
}