专业编程基础技术教程

网站首页 > 基础教程 正文

html固定定位position值fixed(htmldiv固定位置)

ccvgpt 2024-07-19 12:59:01 基础教程 7 ℃

固定定位:(1)给自身设置宽高。(2)再设置position:fixed

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <style type="text/css">
		.posi_flex{
			height: 100px;
			width: 100%;
			position: fixed;
			border: 1px solid red;
		}
	</style>
</head>
<body>
	<div class="posi_flex">
		这是顶部元素内容固定在顶部的
	</div>
	
	<div style="height:800px; padding-top:116px;">1</div>
	普通文本信息<br/>
	普通文本信息<br/>
	普通文本信息<br/>
	普通文本信息<br/>
	普通文本信息<br/>
</body>
<script type="text/javascript">
</script>
</html>

html固定定位position值fixed(htmldiv固定位置)

Tags:

最近发表
标签列表