使用2D转换中的缩放:transform: scale(0.5); (设置一个父盒子,给父盒子设置缩小)
// 原来的盒子
.old {
width: 200px;
height: 200px;
}
// 新的盒子(父盒子)
.new {
width: 400px;
height: 400px;
border: 1px solid;
transform: scale(0.5);
position: absolute;
top: 0;
left: 0;
}
// 优化
.old::before {
width: 400px;
height: 400px;
border: 1px solid;
transform: scale(0.5);
position: absolute;
top: 0;
left: 0;
}