代码如下,当给xx加上position:fixed,为什么xx在样式上从占一整行,到只包围了xxx。
<!DOCTYPE html><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script src="http://libs.baidu.com/jquery/2.0.0/jquery.js" type="text/javascript"></script><style type="text/css">.xxx{height: 100px;width: 100px;background: red;}.xx{ background: black; padding: 10px; /*position: fixed;*/ left: 100px;}</style></head> <body><div class="xx"> <div class="xxx"> </div></div><script type="text/javascript"></script></body> </html>
position:fixed会脱离文档流
内容被它的子元素撑开