Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何保持头部静止?_Html_Css - Fatal编程技术网

Html 如何保持头部静止?

Html 如何保持头部静止?,html,css,Html,Css,我是一个新手,正在做一个项目来学习和提高我的网页设计技能。我想知道如何使我的标题保持静态?当我向下滚动页面时,它应该向下移动。有什么帮助吗?我假设您要求的是一个固定的标题,在向下滚动页面时,该标题保持不变 简单的解决方案是在CSS文件中添加如下CSS规则,并确保头html的id定义为“yourheader” 我希望这能有所帮助。我想是这样吧 位置:固定 top:0;=固定到顶部 底部:0;=固定到底部 等等,左,右 html: <div class="header"> Thi

我是一个新手,正在做一个项目来学习和提高我的网页设计技能。我想知道如何使我的标题保持静态?当我向下滚动页面时,它应该向下移动。有什么帮助吗?

我假设您要求的是一个固定的标题,在向下滚动页面时,该标题保持不变

简单的解决方案是在CSS文件中添加如下CSS规则,并确保头html的id定义为“yourheader”


我希望这能有所帮助。

我想是这样吧

位置:固定
top:0;=固定到顶部
底部:0;=固定到底部

等等,左,右

html:

<div class="header">
    This is my header!!!
</div>
<div class="content">Content goes here!!!!</div>
<div class="header">
    This is my header!!!
</div>
<div class="content">Content goes here!!!!</div>
body {
    margin:0;
}

.header
{
    background:#454545;
    position:fixed; 
    top: 0;
    width:100%;
    padding:5px;
    height: 25px;
}

.content
{
    margin: 35px;
}