以下为ChatGPT自动生成的解答,正确与否请自行判断。
BFE.devAI解答 - 前端面试问题
129. 如何在CSS中实现正方形?
可以使用padding或者line-height来实现,比如:
.square {
width: 100px;
height: 0;
padding-bottom: 100px;
background-color: red;
}
或者
.square {
display: inline-block;
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
background-color: red;
}