建立一个正方形的div 的办法.
访问量: 3011
1. 使用纯css:
div {
background:orange;
width:20%;
padding-top:20%; /* 这是一种hack , 但是很优雅 */
}
源代码: http://stackoverflow.com/a/21537905/445908
2. 使用jQuery:
$(dom).css({height: $(dom).height()})
访问量: 3011
1. 使用纯css:
div {
background:orange;
width:20%;
padding-top:20%; /* 这是一种hack , 但是很优雅 */
}
源代码: http://stackoverflow.com/a/21537905/445908
2. 使用jQuery:
$(dom).css({height: $(dom).height()})