这是我的全部代码。我只是想知道这到底出了什么问题,我的下拉列表没有显示在导航栏中。我只是想知道是否有人能帮我解决这个问题,我在html和css还是个新手。
<html>
<head>
<title> Curriculum </title>
<style>
body {
margin: 0;
padding: 0;
background: #333;
background-attachment: fixed;
background-size: cover;
}
#video-background {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
}
.header{
width: 1100px;
height: 350px;
margin: auto;
}
.nav{
width 1100px;
margin: auto;
overfow: auto;
}
ul{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: Maroon;
opacity: .8;
}
li{
float: left;
}
li:last-child {
border-right: none;
}
a:link{
color: cyan;
widht: 125px;
text-decoration: none;
display: block;
text-alignment: center;
padding: 15px;
text-transfrom: uppercase;
font-size: 18px;
font-family: verdana;
}
li a {
display: block;
color: yellow;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: cyan;
}
.active {
background-color: White;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: white;
width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
.desc {
padding: 15px;
text-align: center;
}
.dropbtn {
background-color: Maroon;
color: yellow;
padding: 16px;
font-size: 18px;
border: none;
cursor: pointer;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropbtn {
background-color: cyan;
}
</style>
</head>
<body>
<video autoplay loop id="video-background" muted plays-inline>
<source src="A.mp4" type="video/mp4">
</video>
<div class = "header">
<img src = "Header.jpg" width = "1100px" height = "150px">
<div class = "nav">
<ul>
<li><a href = "Home.html #Home"> Home </a></li>
<li><a href = "Mission_Vision.html #Mission & Vision"> Mission & Vision </a></li>
<li><a href = "#"> Org.Chart </a></li>
<li><div class="dropdown">
<button class="dropbtn">Curriculum</button>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
</li>
<li style="float:right"><a href="Contact.html#about">Contact Us</a></li>
</ul>
</div>
</body>
</html>我该如何解决这个问题?帮助我的人提前感谢能帮助我的人。我已经在一些网站上复制了一些代码,但仍然不能工作。
发布于 2017-09-28 19:17:39
您已经在.dropdown中添加了position: relative。
.dropdown-content是.dropdown的子级,放在absolute中
因此,它停留在其父对象的边界内,因此不可见。
卸下position: relative即可正常工作。
body {
margin: 0;
padding: 0;
background: #333;
background-attachment: fixed;
background-size: cover;
}
#video-background {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
}
.header{
width: 1100px;
height: 350px;
margin: auto;
}
.nav{
width 1100px;
margin: auto;
overfow: auto;
}
ul{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: Maroon;
opacity: .8;
}
li{
float: left;
}
li:last-child {
border-right: none;
}
a:link{
color: cyan;
widht: 125px;
text-decoration: none;
display: block;
text-alignment: center;
padding: 15px;
text-transfrom: uppercase;
font-size: 18px;
font-family: verdana;
}
li a {
display: block;
color: yellow;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: cyan;
}
.active {
background-color: White;
}
.dropdown {
/*position: relative; < remove this line */
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: white;
width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
.desc {
padding: 15px;
text-align: center;
}
.dropbtn {
background-color: Maroon;
color: yellow;
padding: 16px;
font-size: 18px;
border: none;
cursor: pointer;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropbtn {
background-color: cyan;
}<video autoplay loop id="video-background" muted plays-inline>
<source src="A.mp4" type="video/mp4">
</video>
<div class = "header">
<img src = "Header.jpg" width = "1100px" height = "150px">
<div class = "nav">
<ul>
<li><a href = "Home.html #Home"> Home </a></li>
<li><a href = "Mission_Vision.html #Mission & Vision"> Mission & Vision </a></li>
<li><a href = "#"> Org.Chart </a></li>
<li><div class="dropdown">
<button class="dropbtn">Curriculum</button>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
</li>
<li style="float:right"><a href="Contact.html#about">Contact Us</a></li>
</ul>
</div>
https://stackoverflow.com/questions/46467733
复制相似问题