- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的网页顶部有一个固定的导航菜单,网页右侧有另一个导航菜单。但是,我的顶部(固定)导航菜单导致滚动条位于导航菜单 div 的后面。我尝试寻找解决方案,发现我应该删除 overflow: auto 在我的 html 中,body 选择器。但是,如果我这样做,则右侧的导航菜单不会扩展到文档的整个高度 (100%)。我该如何解决这个问题?
html,
body {
height: 100%;
background-color: white;
margin: 0px;
padding: 0px;
font-family: "Gill Sans", sans-serif;
overflow: auto;
z-index: 50;
}
body {
min-height: 100%;
}
.navigation-menu {
position: fixed;
top: 0px;
width: 100%;
background-color: black;
z-index: 60;
}
.menu {
position: relative;
top: 0px;
list-style: none;
padding: 0px;
margin: 0px;
background-color: #6157CC;
}
.navigation-menu a {
float: left;
padding: 15px 20px;
color: white;
text-decoration: none;
}
h1 {
color: #6157CC;
text-align: center;
position: relative;
top: 90px;
z-index: 1;
margin: 0px 0px 0px 170px;
}
.contents {
float: left;
position: absolute;
width: 15%;
height: 100%;
background-color: red;
z-index: 5;
display: block;
overflow: auto;
}
#plants {
list-style: none;
position: absolute;
top: 3%;
text-align: center;
}
#plants a {
position: relative;
display: block;
padding: 25px 10px;
top: 20px;
color: white;
text-decoration: none;
}
.plants-definition {
position: relative;
float: right;
width: 85%;
top: 80px;
left: 0px;
}
p {
margin: 20px 50px;
}
h2 {
padding: 55px 0px 0px 0px;
margin: 0px 50px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="Nature.CSS">
<meta charset="UTF-8">
<title>Nature</title>
</head>
<body>
<div class="navigation-menu">
<nav>
<ul class="menu">
<li><a>Home</a></li>
<li><a>Plants</a></li>
<li><a>Animals</a></li>
<li><a>Oceans</a></li>
</ul>
</nav>
</div>
<div class="contents">
<ul id="plants">
<li><a>Trees</a></li>
<li><a>Flowers</a></li>
<li><a>Water Plants</a></li>
</ul>
</div>
<div>
<h1>Plants</h1>
</div>
<div class="plants-definition">
<h2>Trees</h2>
<p>In botany, a tree is a perennial plant with an elongated stem, or trunk, supporting branches and leaves in most species. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are usable
as lumber or plants above a specified height. Trees are not a taxonomic group but include a variety of plant species that have independently evolved a woody trunk and branches as a way to tower above other plants to compete for sunlight. Trees tend
to be long-lived, some reaching several thousand years old. In wider definitions, the taller palms, tree ferns, bananas, and bamboos are also trees. Trees have been in existence for 370 million years. It is estimated that there are just over 3 trillion
mature trees in the world</p>
</div>
<div>
<h2>Flowers</h2>
<p></p>
</div>
<div class="plants-definition">
<h2>Flowers</h2>
<p>A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to effect reproduction, usually by providing
a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) or allow selfing (fusion of sperm and egg from the same flower). Some flowers produce diaspores
without fertilization (parthenocarpy). Flowers contain sporangia and are the site where gametophytes develop. Many flowers have evolved to be attractive to animals, so as to cause them to be vectors for the transfer of pollen. After fertilization,
the ovary of the flower develops into fruit containing seeds.</p>
</div>
<div class="plants-definition">
<h2>Water Plants</h2>
<p>Aquatic plants are plants that have adapted to living in aquatic environments (saltwater or freshwater). They are also referred to as hydrophytes or macrophytes. A macrophyte is an aquatic plant that grows in or near water and is either emergent,
submergent, or floating, and includes helophytes (a plant that grows in marsh, partly submerged in water, so that it regrows from buds below the water surface).[1] In lakes and rivers macrophytes provide cover for fish and substrate for aquatic
invertebrates, produce oxygen, and act as food for some fish and wildlife.</p>
</div>
</body>
</html>
https://jsfiddle.net/e679hmx4/2/
(我知道现在看起来一点都不好看,但我想你应该能理解大概的意思)。
最佳答案
您的问题是因为 html, body
上的 overflow: auto
。如果您删除它,您的滚动条将按预期显示:
html, body { height: 100%; background-color: white; margin: 0px; padding: 0px; font-family: "Gill Sans", sans-serif;overflow: auto;z-index: 50;}
Once you've done this, you'll also need to set your side navbar (.content
) to position: fixed
such that it fills the correct height.
See example below:
html,
body {
height: 100%;
background-color: white;
margin: 0px;
padding: 0px;
font-family: "Gill Sans", sans-serif;
z-index: 50;
}
body {
min-height: 100%;
}
.navigation-menu {
position: fixed;
top: 0px;
width: 100%;
background-color: black;
z-index: 60;
}
.menu {
position: relative;
top: 0px;
list-style: none;
padding: 0px;
margin: 0px;
background-color: #6157CC;
}
.navigation-menu a {
float: left;
padding: 15px 20px;
color: white;
text-decoration: none;
}
h1 {
color: #6157CC;
text-align: center;
position: relative;
top: 90px;
z-index: 1;
margin: 0px 0px 0px 170px;
}
.contents {
float: left;
position: fixed;
/* change position to fixed */
width: 15%;
height: 100%;
background-color: red;
z-index: 5;
display: block;
overflow: auto;
}
#plants {
list-style: none;
position: absolute;
top: 3%;
text-align: center;
}
#plants a {
position: relative;
display: block;
padding: 25px 10px;
top: 20px;
color: white;
text-decoration: none;
}
.plants-definition {
position: relative;
float: right;
width: 85%;
top: 80px;
left: 0px;
}
p {
margin: 20px 50px;
}
h2 {
padding: 55px 0px 0px 0px;
margin: 0px 50px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="Nature.CSS">
<meta charset="UTF-8">
<title>Nature</title>
</head>
<body>
<div class="navigation-menu">
<nav>
<ul class="menu">
<li><a>Home</a></li>
<li><a>Plants</a></li>
<li><a>Animals</a></li>
<li><a>Oceans</a></li>
</ul>
</nav>
</div>
<div class="contents">
<ul id="plants">
<li><a>Trees</a></li>
<li><a>Flowers</a></li>
<li><a>Water Plants</a></li>
</ul>
</div>
<div>
<h1>Plants</h1>
</div>
<div class="plants-definition">
<h2>Trees</h2>
<p>In botany, a tree is a perennial plant with an elongated stem, or trunk, supporting branches and leaves in most species. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are usable
as lumber or plants above a specified height. Trees are not a taxonomic group but include a variety of plant species that have independently evolved a woody trunk and branches as a way to tower above other plants to compete for sunlight. Trees tend
to be long-lived, some reaching several thousand years old. In wider definitions, the taller palms, tree ferns, bananas, and bamboos are also trees. Trees have been in existence for 370 million years. It is estimated that there are just over 3 trillion
mature trees in the world</p>
</div>
<div>
<h2>Flowers</h2>
<p></p>
</div>
<div class="plants-definition">
<h2>Flowers</h2>
<p>A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to effect reproduction, usually by providing
a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) or allow selfing (fusion of sperm and egg from the same flower). Some flowers produce diaspores
without fertilization (parthenocarpy). Flowers contain sporangia and are the site where gametophytes develop. Many flowers have evolved to be attractive to animals, so as to cause them to be vectors for the transfer of pollen. After fertilization,
the ovary of the flower develops into fruit containing seeds.</p>
</div>
<div class="plants-definition">
<h2>Water Plants</h2>
<p>Aquatic plants are plants that have adapted to living in aquatic environments (saltwater or freshwater). They are also referred to as hydrophytes or macrophytes. A macrophyte is an aquatic plant that grows in or near water and is either emergent,
submergent, or floating, and includes helophytes (a plant that grows in marsh, partly submerged in water, so that it regrows from buds below the water surface).[1] In lakes and rivers macrophytes provide cover for fish and substrate for aquatic
invertebrates, produce oxygen, and act as food for some fish and wildlife.</p>
</div>
</body>
</html>
关于html - 是什么导致滚动条落后于固定的div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55889942/
let config = [{ name: 1, state: 1, output: 'Y', }, { name: 2, state: 1, outp
我在使用 C# 统一编程时遇到了一些问题。我试图在开始游戏时请求一个插页式广告,这样我就可以在玩家死亡 5 次时显示它。问题是,当我遇到第 5 次死亡时,广告将不会显示。当我尝试在关卡开始时请求广告时
我有 JPanel,从中打开一个扩展 AbstractAIFDialog 的搜索条件对话框。它由搜索条件文本字段、结果 TableView 和搜索按钮组成。单击“搜索”后,在此对话框中,我需要显示进度
所以,我的蛇做了连续的运动,但如果我按任意键,它就会及时倒退并前后滞后。这是视频:https://youtu.be/KCesu5bGiS8 我的猜测是更快地更新按键输入,但是当我这样做时,所有内容都会
我正在尝试获得 TODAY THE CURRENT 的所有选票,并且我几乎已经通过以下 mysql 查询实现了这一点,但是有一个问题。 这段代码让我获得了今天的选票: SELECT COUNT(*)
我正在使用 RS256 算法生成 Azure AD token 。 当我解码 https://jwt.io/ 中的 token 时发出的时间比请求时间晚了 5 分钟。 请求的时间:美国标准时间晚上 9
当我查询 NOW() 时,mysql 返回的时间与服务器上的当前时间相差大约 -30 秒。有任何想法吗?我尝试查看配置文件,但一无所获。我正在运行 5.1.37 版本 SELECT NOW() 最佳答
我正在做一个开源项目。我首先 fork 这个项目,将它克隆到我的机器上,然后直接在 master 分支上进行了更改。我提交了这些更改并将其推到我的 fork 上。然后我打开了该更改的 pull 请求。
所以我用了大约 20 分钟写出了这个程序,并花了最后 40 分钟绞尽脑汁地想为什么它返回 21131 而不是 21124,这似乎是正确的答案。我知道代码没有问题(很可能),因为它适用于我测试的每个数字
我在使用 QueryDsl 日期算法时遇到问题。它对我不起作用,会引发以下错误: Caused by: org.postgresql.util.PSQLException: ERROR: functi
嗨,我正在玩 Angular ui 时间选择器 http://angular-ui.github.io/bootstrap/ 当我使用它时,我的日期晚了 1 小时,我该如何更改它以及为什么? JS
我是一名优秀的程序员,十分优秀!