Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.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,我有两个div,它们水平堆叠在一起 每个div占据100%的查看端口 .section{ width:100%; height:100%; } 在每个div中,都有一个锚定到另一个div <div class="first section "> <a name="first-section">&nbsp;</a> <p>Click <a href="#second-section">here</a> to go t

我有两个
div
,它们水平堆叠在一起

每个
div
占据100%的查看端口

.section{
width:100%;
height:100%;
}
在每个
div
中,都有一个锚定到另一个div

<div class="first section ">
<a name="first-section">&nbsp;</a>
<p>Click <a href="#second-section">here</a> to go to the second section</p> 
</div>

<div class="second section">
<p>Click <a href="#first-section">here</a> to go to the first section</p> 
</div>
<a name="second-section">&nbsp;</a>

转到第二部分

单击以转到第一部分

我的目标是每次只显示一个
div
的内容。但是当一个位于第二部分
div
并调整页面大小时,当页面大小调整到初始大小时,将显示两个
div

调整页面大小时如何避免向上滚动?
我有
正文{overflow:hidden;}
。谢谢。

您可以将div设置为
位置:fixed
,因此它始终相对于视口。然后,默认情况下隐藏除第一个div之外的所有div,并在其打开时显示该div

html,正文{高度:100%;}
正文{页边距:0;}
.科{
宽度:100%;
身高:100%;
位置:固定;
}
.章节:目标{
能见度:可见;
}
.首先{
背景:浅蓝色;
}
.第二{
背景:浅绿色;
可见性:隐藏;
}

单击以转到第二部分

单击以转到第一部分