2016-06-16 22 views
0

thisのように動作するホバーのドロップダウンメニューを作成しようとしています。ホバーのドロップダウンメニューが表示されない

しかし、私のウェブサイトのドロップダウンメニューは表示されないようです。

(Chromeのデベロッパーツールを使用して)コードを調べたところ、私のドロップダウンメニューは私の#content divで覆われていました。

トップにドロップダウンメニューを表示するにはどうすればよいですか?

body { 
 
    margin: 0; 
 
    font-family: "Comic Sans MS", cursive, sans-serif; 
 
    background-color: #000000; 
 
    background-size: cover; 
 
    background-attachment: fixed; 
 
    color: #ffffff; 
 
    background-image: url("../background/home.jpg") 
 
} 
 

 
@keyframes fadein { 
 
    from { 
 
    opacity: 0; 
 
    } 
 
    to { 
 
    opacity: 1; 
 
    } 
 
} 
 

 
#home { 
 
    float: left; 
 
    font-size: 1.5em; 
 
} 
 

 
ul { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    overflow: hidden; 
 
    background-color: rgba(236, 130, 53, 0.75); 
 
    position: fixed; 
 
    top: 0; 
 
    width: 100%; 
 
} 
 

 
li { 
 
    float: right; 
 
} 
 

 
li a { 
 
    display: block; 
 
    color: white; 
 
    text-align: center; 
 
    padding: 14px 16px; 
 
    text-decoration: none; 
 
} 
 

 
a { 
 
    transition: all 0.5s; 
 
} 
 

 
#content { 
 
    margin-top: 61px; 
 
    animation: fadein 5s; 
 
} 
 

 
.menu a { 
 
    color: #0000ff; 
 
    font-size: 1.5em; 
 
    font-weight: bold; 
 
} 
 

 
.menu a:hover { 
 
    background-color: #ff0000; 
 
    color: #ffffff; 
 
} 
 

 
.menu { 
 
    display: inline-block 
 
} 
 

 
.dropdown-content { 
 
    display: none; 
 
    position: absolute; 
 
    background-color: #f9f9f9; 
 
    min-width: 160px; 
 
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); 
 
} 
 

 
.dropdown-content a { 
 
    color: black; 
 
    padding: 12px 16px; 
 
    text-decoration: none; 
 
    display: block; 
 
    text-align: left; 
 
} 
 

 
.dropdown-content a:hover { 
 
    background-color: #f1f1f1 
 
} 
 

 
.menu:hover .dropdown-content { 
 
    display: block; 
 
}
<body> 
 
    <div id="navigation-menu"> 
 
    <ul> 
 
     <li class="menu"> 
 
     <a href="#">Transport</a> 
 
     <div class="dropdown-content"> 
 
      <a href="#">Link 1</a> 
 
      <a href="#">Link 2</a> 
 
      <a href="#">Link 3</a> 
 
     </div> 
 
     </li> 
 
    </ul> 
 
    </div> 
 
    <div id="content"> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    </div> 
 
</body>

答えて

1

これはあなたが探している効果を与えるために、DIVの外側を流れるからコンテンツを停止した<ul>

ul { 
    list-style-type: none; 
    margin: 0; 
    padding: 0; 
    background-color: rgba(236, 130, 53, 0.75); 
    position: fixed; 
    top: 0; 
    width: 100%; 
} 

からoverflow: hidden;を削除します。

+0

問題が解決しました。ご協力いただきありがとうございます –

0

ulからoverflow: hiddenを削除します。 .dropdown-contentが表示されていません。

body { 
 
    margin: 0; 
 
    font-family: "Comic Sans MS", cursive, sans-serif; 
 
    background-color: #000000; 
 
    background-size: cover; 
 
    background-attachment: fixed; 
 
    color: #ffffff; 
 
    background-image: url("../background/home.jpg") 
 
} 
 

 
@keyframes fadein { 
 
    from { 
 
    opacity: 0; 
 
    } 
 
    to { 
 
    opacity: 1; 
 
    } 
 
} 
 

 
#home { 
 
    float: left; 
 
    font-size: 1.5em; 
 
} 
 

 
ul { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    background-color: rgba(236, 130, 53, 0.75); 
 
    position: fixed; 
 
    top: 0; 
 
    width: 100%; 
 
} 
 

 
li { 
 
    float: right; 
 
} 
 

 
li a { 
 
    display: block; 
 
    color: white; 
 
    text-align: center; 
 
    padding: 14px 16px; 
 
    text-decoration: none; 
 
} 
 

 
a { 
 
    transition: all 0.5s; 
 
} 
 

 
#content { 
 
    margin-top: 61px; 
 
    animation: fadein 5s; 
 
} 
 

 
.menu a { 
 
    color: #0000ff; 
 
    font-size: 1.5em; 
 
    font-weight: bold; 
 
} 
 

 
.menu a:hover { 
 
    background-color: #ff0000; 
 
    color: #ffffff; 
 
} 
 

 
.menu { 
 
    display: inline-block 
 
} 
 

 
.dropdown-content { 
 
    display: none; 
 
    position: absolute; 
 
    background-color: #f9f9f9; 
 
    min-width: 160px; 
 
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); 
 
} 
 

 
.dropdown-content a { 
 
    color: black; 
 
    padding: 12px 16px; 
 
    text-decoration: none; 
 
    display: block; 
 
    text-align: left; 
 
} 
 

 
.dropdown-content a:hover { 
 
    background-color: #f1f1f1 
 
} 
 

 
.menu:hover .dropdown-content { 
 
    display: block; 
 
}
<body> 
 
    <div id="navigation-menu"> 
 
    <ul> 
 
     <li class="menu"> 
 
     <a href="#">Transport</a> 
 
     <div class="dropdown-content"> 
 
      <a href="#">Link 1</a> 
 
      <a href="#">Link 2</a> 
 
      <a href="#">Link 3</a> 
 
     </div> 
 
     </li> 
 
    </ul> 
 
    </div> 
 
    <div id="content"> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    <p>Content goes here</p> 
 
    </div> 
 
</body>

関連する問題