84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
就是让网页里的内容随着浏览器窗口改变时跟着自动居中呢……怎样实现?有好点的常用的思路吗
小伙看你根骨奇佳,潜力无限,来学PHP伐。
用js获取窗口大小和元素位置,然后根据拿到的值去设置内容位置,纯css也可以,但是感觉灵活度不够高
推荐一下自己的博客:http://blog.csdn.net/zp1996323/article/details/50936259,实现的效果都是垂直居中水平居中
margin-right:auto;margin-left:auto
position: absolute;left:0;right:0;top:0;bottom:0;margin:auto;width:XXpx;height:XXpx;
position: absolute; left:0; right:0; top:0; bottom:0; margin:auto; width:XXpx; height:XXpx; 这个方法不兼容IE6/7,移动端考虑可以使用。
1、css实现方法(width和height事先知道):需要居中的层采用绝对定位,结合left、top、margin-left和margin-top实现居中。2、js实现,这个就不多说了。
用js获取窗口大小和元素位置,然后根据拿到的值去设置内容位置,纯css也可以,但是感觉灵活度不够高
推荐一下自己的博客:http://blog.csdn.net/zp1996323/article/details/50936259,实现的效果都是垂直居中水平居中
margin-right:auto;
margin-left:auto
position: absolute;
left:0;
right:0;
top:0;
bottom:0;
margin:auto;
width:XXpx;
height:XXpx;
1、css实现方法(width和height事先知道):需要居中的层采用绝对定位,结合left、top、margin-left和margin-top实现居中。
2、js实现,这个就不多说了。