- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经在我试图创建的站点内实现了一个导航栏,但是,导航栏的所有下拉选项唯一一次出现是在它位于页面顶部时。一旦我向下滚动页面,选项就会一个接一个地隐藏起来。 (如果你特别看一下个人资料按钮,你会看到一个按钮在另一个按钮后面,因为 :hover 是不同的颜色。)
我在 CSS 中用溢出和定位弄乱了一点。使溢出显示与 overflow hidden 。我已经从 header 中删除了导航栏以查看这是否是一个问题,同时从 HTML 中删除了 header 以查看那里是否存在问题。
p {
padding: 13px;
text-align: justify;
}
.nav {
position: fixed;
width: 100%;
top: 0;
}
.nav a {
position: fixed;
background-color: #333;
z-index: 9999;
overflow: show;
}
.nav a.home-btn {
position: relative;
}
.nav a.logout-btn {
position: relative;
}
#head1 {
text-align: center;
background-color: black;
color: white;
font-family: sans-serif;
text-decoration: none;
font-size: 30px;
padding: 10px 14px;
}
* {
margin: 0;
padding: 0;
font-family: sans-serif;
list-style: none;
text-decoration: none;
z-index: 9999;
}
.navbar {
overflow: hidden;
background-color: #333;
font-family: sans-serif;
z-index: 9999;
}
.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.profile-dropdown {
float: left;
overflow: hidden;
}
.profile-dropdown .profile-btn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.profile-content {
display: none;
position: absolute;
background-color: #333;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.profile-content a {
float: none;
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.profile-content a:hover {
background-color: gray;
}
.profile-dropdown:hover .profile-content {
display: block;
}
.search-dropdown {
float: left;
overflow: hidden;
}
.search-dropdown .search-btn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.search-btn:hover,
.profile-btn:hover,
.home-btn:hover,
.logout-btn:hover {
background-color: #2ecc71;
}
.navbar a.logout-btn {
float: right;
}
.search-content {
display: none;
position: absolute;
background-color: #333;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.search-content a {
float: none;
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.search-content a:hover {
background-color: gray;
}
.search-dropdown:hover .search-content {
display: block;
}
.listings-dropdown {
float: left;
overflow: hidden;
}
.listings-dropdown .listings-btn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.listings-content {
display: none;
position: absolute;
background-color: #333;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.listings-content a {
float: none;
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.listings-content a:hover {
background-color: gray;
}
.listings-dropdown:hover .listings-content {
display: block;
}
.listings-btn:hover {
background-color: #2ecc71;
}
.messages-dropdown {
float: left;
overflow: hidden;
}
.messages-dropdown .messages-btn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.messages-content {
display: none;
position: absolute;
background-color: #333;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.messages-content a {
float: none;
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.messages-content a:hover {
background-color: gray;
}
.messages-dropdown:hover .messages-content {
display: block;
}
.messages-btn:hover {
background-color: #2ecc71;
}
.settings-dropdown {
float: left;
overflow: hidden;
}
.settings-dropdown .settings-btn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.settings-content {
display: none;
position: absolute;
background-color: #333;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.settings-content a {
float: none;
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.settings-content a:hover {
background-color: gray;
}
.settings-dropdown:hover .settings-content {
display: block;
}
.settings-btn:hover {
background-color: #2ecc71;
}
.sticky {
position: fixed;
top: 0;
width: 100%;
}
<html>
<link rel="stylesheet" href="../css/searchLost.css" />
<link rel="stylesheet" href="https://cdnjs.cloudfare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<body>
<div class="header">
<h1 id="head1">Lost And Found</h1>
</div>
<div class="navbar">
<a href="mainPage.html" class="home-btn">Home</a>
<div class="profile-dropdown">
<button class="profile-btn">Profile<i class="fa fa-caret-down"></i></button>
<div class="profile-content">
<a href="index.html">Your Listings</a>
<a href="#">Update Info</a>
</div>
</div>
<div class="search-dropdown">
<button class="search-btn">Search<i class="fa fa-caret-down"></i></button>
<div class="search-content">
<a href="#">Search Lost</a>
<a href="#">Search Found</a>
</div>
</div>
<div class="listings-dropdown">
<button class="listings-btn">Listings<i class="fa fa-caret-down"></i></button>
<div class="listings-content">
<a href="#">Report Lost</a>
<a href="#">Report Found</a>
</div>
</div>
<div class="messages-dropdown">
<button class="messages-btn">Messages<i class="fa fa-caret-down"></i></button>
<div class="messages-content">
<a href="#">New</a>
<a href="#">Sent</a>
<a href="#">Deleted</a>
</div>
</div>
<div class="settings-dropdown">
<button class="settings-btn">Settings<i class="fa fa-caret-down"></i></button>
<div class="settings-content">
<a href="#">Change Password</a>
</div>
</div>
<a href="index.html" class="logout-btn">Logout</a>
</div>
<script type="text/javascript">
var nav = document.getElementsByClassName('navbar');
window.onscroll = function sticky() {
if (window.pageYOffset > nav[0].offsetTop) {
nav[0].classList.add('nav');
} else {
nav[0].classList.remove('nav');
}
};
</script>
<p>
Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the
page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out
the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page. Sample text to fill out the page.
</p>
</body>
</html>
我想要的是让导航栏显示所有下拉选项,而不管导航栏的位置如何,无论它是在页面顶部一直滚动到顶部,还是在滚动时在顶部下。
最佳答案
您为每个下拉菜单使用了不同的 css 类,这对您的工作和其他人帮助您都具有挑战性。我修复了个人资料下拉列表,剩下的由你决定。把它当作一个学习的机会。您应该为所有下拉菜单使用相同的 css 类,它们中的任何一个都没有足够的不同来保证只为给定的下拉菜单设置一个类。
此外,下次您提交代码时,我们将提供一个 jsfiddle
https://jsfiddle.net/3qwy26rp/22/
.profile-content {
display: none;
position: fixed;
background-color: #333;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.profile-content a {
float: none;
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
position: relative;
}
关于javascript - 向下滚动页面后,粘性导航栏不显示所有下拉选项的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56944406/
我试图让我的 jQuery 脚本从单击的链接中提取 url,然后将其插入到我的视频标签中。有什么建议吗? 我试过拼接我从 .html() 中得到的内容,但引号总是搞砸了。
我遇到了 docker 的问题。 场景是这样的:我们使用Codebuild+Packer+docker创建AMI,用于deploy。在这一步中,我们从 Artifactory 中提取图像,并且除了提取
我目前正在学习 RxJS。 在文档中,我找到了这个数组。 我尝试在谷歌上搜索“pull and push javascript”,但我什至不知道如何调用这些实体/概念。我不明白那是什么意思?我假设 S
Title 在小屏幕上,我首先需要标题,然后是文本字段,但在中等以上的屏幕上,我需要相反的方式 - 我已经尝试过推和拉,但它们无法工作 - 有什么想法吗? 最佳答案 根据 Swa
zmq 的某些部分未以可预测的方式运行。 我正在使用 VS2013 和 zmq 3.2.4。为了不在我的 pubsub 框架中“丢失”消息 [旁白:我认为这是一个设计缺陷。我应该能够首先启动我的订阅者
我正在编写一个使用嵌套 Bootstrap 列的页面。我正在使用推/拉让列在移动设备上切换位置,而且效果很好。但是,在桌面上我遇到了一些奇怪的间距问题。嵌套列偏移到父列的右侧。 我设置了一个 fidd
在拉取一些 docker 镜像(但不是全部)时出现此错误: failed to register layer: Error processing tar file(exit status 1): op
我创建了一个 Kubernetes 集群,并为每个节点安装了 docker。 当我尝试使用 docker push local_registry_addr:port/image_id 将图像拉取或推送
没有明确地推/拉单个书签,书签何时从 repo 复制/更新到 repo? 在我对两个本地存储库的测试中,我无法推断出一致的行为。有时从 A 到 B 或 B 到 A 的推/拉会复制/更新书签,有时不会。
在 Bootstrap 3 文档中,他们给出了以下使用 push 和 pull 类更改列顺序 (http://getbootstrap.com/css/#grid-column-ordering) 的
从这个问题开始Three column Bootstrap layout with left sidebar at bottom我了解了 Bootstrap 列推拉。 下面的代码片段几乎可以得到我想要
许多 Repo 函数的签名包括 **kwargs,其中文档说,您可以将参数传递给底层包装的 git 命令。但是,*args 没有位置。为了传递类似标志的参数,如 --all。我原以为它们会像 my_r
如果您将大文件推送/拉到设备上,这真的很烦人,现在无法知道它有多远。是否可以运行 adb push 或 adb pull 并使用“bar”实用程序获取进度条? 这里的主要问题是我认为 adb 需要两个
当我尝试使用 Gitkrakent 向/从 Heroku 推/拉时,GitKraken 告诉我: "Please log in to continue" 请求的“用户/登录”是什么? (我个人 Her
我在 docker 容器中有一个 Jenkins 2.150.1。要安装这个 Jenkins,我只需使用 jenkinsci/blueocean:1.9.0图片。 我创建了一个管道,然后尝试使用我的
我想使用 Jenkins 做下一步: 1- docker pull 2- docker run -i -t 我已经在jenkins上安装了docker插件,但是这可行吗? docker plugi
如果我正在处理一些我不想提交的文件,我只需保存它们。然后我有其他文件想要推送到服务器,但是如果其他人对存储库进行了更改,并且我将它们拉下来,它会要求我 merge 或 rebase ..但是这些选项中
无论出于何种原因,我在 FB 上共享链接时尝试使用的图像都无法加载。给出的确切错误是: 提供了og:image,无法下载。发生这种情况的原因有多种,例如您的服务器使用不受支持的内容编码。爬虫接受 de
今天我买了三星 Galaxy Note 3,它配备了 Android 4.3。由于它太新了,我找不到根植我设备的方法,所以我尝试使用 adb 连接……我失败了。 所以,我用了这个 D:\android
我尝试通过 airflow cli test 命令测试 2 个任务` 第一个任务运行,自动将最后一个控制台推送到 xcom,我按预期在 Airflow GUI 中看到了值 some value 当我通
我是一名优秀的程序员,十分优秀!