2017-09-28 28 views
0

これは私のコード全体です。私はちょうどこれに間違って何かをさまよって、私のドロップダウンはnavbarに表示されていません。私はこの問題のためにここで私を助けることができる場合、私はまだ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> 

私はこの問題は私に私を助けることができる誰かのため事前に誰かのおかげを助ける方法を修正します。私は既にいくつかのサイトでいくつかのコードをコピーしましたが、まだ動作していません。

答えて

1

position: relative.dropdownに追加しました。
.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>

関連する問題