w3c认为margin叠加是合理的。不管是不是bug,但是这个问题真的存在。看下面这个例子:
- < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
margin: 20px automargin: 20px auto margin: 20px auto margin: 20px automargin: 50px auto
解决这个问题的方法有不少,先来看看这个,在外层的容器中加:overflow:hidden;zoom:1;
- < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
这里两个还是存在叠加margin: 20px auto这里两个还是存在叠加margin: 20px auto margin: 20px auto margin: 20px automargin: 50px auto
还有外层的容器中加边框属性,在叠加元素加空块状元素等等。。还有就是用padding来取代margin
http://m.bbyears.com/flash/22309.html
推荐访问:cssci css3 cssci2019-2020