Home > Web Front-end > HTML Tutorial > position:fixed对元素影响的疑问?_html/css_WEB-ITnose

position:fixed对元素影响的疑问?_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:04:08
Original
1316 people have browsed it

代码如下,当给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>
Copy after login



回复讨论(解决方案)

position:fixed会脱离文档流
内容被它的子元素撑开

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template