2017-12-14 11 views
-1

問題は、選択ドロップダウンをクリックするたびに、その後に<div>の後ろに開きます。私はz-indexを試みましたが、うまくいきませんでした。ドロップダウンメニューがコンテナの後ろに隠される

body { 
 
    font: 1.5em Arial; 
 
    background-image: url('prague2.jpeg'); 
 
    background-size: cover; 
 
} 
 

 
.top { 
 
    opacity: 0.8; 
 
    font-size: 65px; 
 
    font-family: Courier new; 
 
    text-align: center; 
 
    background: #EBA23C; 
 
    width: 100%; 
 
} 
 

 
ul { 
 
    float: right; 
 
    margin: 0px; 
 
    padding: 0px; 
 
    list-style: none; 
 
} 
 

 
ul li { 
 
    float: left; 
 
    width: 200px; 
 
    height: 40px; 
 
    background-color: #F05050; 
 
    text-align: center; 
 
    font-size: 20px; 
 
    line-height: 40px; 
 
    margin-right: 2px; 
 
} 
 

 
ul li a { 
 
    text-decoration: none; 
 
    color: white; 
 
    display: block; 
 
} 
 

 
ul li a:hover { 
 
    background-color: #C6AEF0; 
 
} 
 

 
ul li ul li { 
 
    display: none; 
 
} 
 

 
ul li:hover ul li { 
 
    display: block; 
 
} 
 

 
.container { 
 
    line-height: 35px; 
 
    font-style: Lucida Console; 
 
    font-size: 22px; 
 
    opacity: 0.8; 
 
    background: #F0E3CA; 
 
    float: left; 
 
    width: 450px; 
 
    height: 630px; 
 
    border: 2px solid; 
 
    border-radius: 15px; 
 
} 
 

 
.container-inner { 
 
    border-radius: 15px; 
 
    background: #F05050; 
 
    text-align: center; 
 
    width: 450px; 
 
    height: 40px; 
 
    float: left; 
 
    border: 2px solid; 
 
} 
 

 
.container2 { 
 
    background-color: #ccc; 
 
    width: 650px; 
 
    margin-left: 780px; 
 
    margin-top: 30px; 
 
    font-size: 50px; 
 
    font-family: Courier New; 
 
    opacity: 0.7; 
 
    text-align: center; 
 
    border: dashed; 
 
} 
 

 
.bachelor { 
 
    font-size: 40px; 
 
    background-color: #ccc; 
 
    border: 2px solid; 
 
    width: 800px; 
 
    height: 100px; 
 
    margin-left: 710px; 
 
    margin-right: 650px; 
 
    text-align: center; 
 
    opacity: 0.6; 
 
    font-family: Courier New; 
 
    font-style: bold; 
 
}
<div class="top">Study in Czech Republic</div><br> 
 
<ul> 
 
    <li><a>Home</a></li> 
 
    <li><a>News</a></li> 
 
    <li><a>Czech Republic</a> 
 
    <ul> 
 
     <li><a>Facts and figures</a></li> 
 
     <li><a>Area</a></li> 
 
     <li><a>Climate</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a>Study</a> 
 
    <ul> 
 
     <li><a>How to apply</a></li> 
 
     <li><a>Programmes</a></li> 
 
     <li><a>Scholarships</a></li> 
 
     <li><a>Tuition fees</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a>Living</a> 
 
    <ul> 
 
     <li><a>Arrival</a></li> 
 
     <li><a>Living costs</a></li> 
 
     <li><a>Work</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a>Contact</a></li> 
 
</ul> 
 
<div class="container-inner">Why study in the Czech Republic</div><br><br> 
 
<div class="container">These days, over 37,000 foreign students are studying in the Czech Republic; and as their universities continue to offer a ton of English-taught courses, more and more students are finding interesting options there. But if you decide to go there, you’ll 
 
    find a large, exciting community of international students just like you. Universities in the Czech Republic also offer a wide range of programmes at the Bachelor’s, Master’s, and Ph.D level; and each university is accredited, meaning that their courses 
 
    are recognised by companies and organisations all over the country and throughout Europe. In the Czech Republic, you can find one of the oldest traditions of higher education, dating all the way back to the 14th century. It probably also means the universities 
 
    are haunted.</div> 
 
<div class="container2"> 
 
    EXPERIENCE STUDYING IN THE HEART OF EUROPE 
 
</div><br> 
 
<div class="bachelor">Bachelor's Degrees in Czech Republic</div>

問題は、私は選択のドロップダウンをクリックしたときに、それがその後の後ろに開く、ということです。私はz-indexを試しましたが、うまくいきませんでした。これは役立つはずの追加

+0

あなたの例のHTMLにopacity: 0.9;を追加するには、これはタイプミスでした、すべてのHTMLは、 ''内部にある、壊れていますか? <>アイコンを使用して問題の実例を作成できますか? – delinear

+0

私は1ヶ月前にコードを開始しました。私は間違ったコードを書いたのに十分な経験がありません。ヘッドタグを削除できますか? –

+1

ようこそスタックオーバーフロー!コードを編集して問題の[mcve]に減らしてください。あなたの現在のコードには、問題の周辺にあるものが多く含まれています。通常、最小単位のサンプルは良い単位テストと似ています。 –

答えて

0

ul li:hover ul { 
    position: relative; 
    z-index: 1; 
} 

全スニペット

body { 
 
    font: 1.5em Arial; 
 
    background-image: url('prague2.jpeg'); 
 
    background-size: cover; 
 
} 
 

 
.top { 
 
    opacity: 0.8; 
 
    font-size: 65px; 
 
    font-family: Courier new; 
 
    text-align: center; 
 
    background: #EBA23C; 
 
    width: 100%; 
 
} 
 

 
ul { 
 
    float: right; 
 
    margin: 0px; 
 
    padding: 0px; 
 
    list-style: none; 
 
} 
 

 
ul li { 
 
    float: left; 
 
    width: 200px; 
 
    height: 40px; 
 
    background-color: #F05050; 
 
    text-align: center; 
 
    font-size: 20px; 
 
    line-height: 40px; 
 
    margin-right: 2px; 
 
} 
 

 
ul li a { 
 
    text-decoration: none; 
 
    color: white; 
 
    display: block; 
 
} 
 

 
ul li a:hover { 
 
    background-color: #C6AEF0; 
 
} 
 

 
ul li ul li { 
 
    display: none; 
 
} 
 

 
ul li:hover ul { 
 
    position: relative; 
 
    z-index: 1; 
 
} 
 

 
ul li:hover ul li { 
 
    display: block; 
 
} 
 

 
.container { 
 
    line-height: 35px; 
 
    font-style: Lucida Console; 
 
    font-size: 22px; 
 
    opacity: 0.8; 
 
    background: #F0E3CA; 
 
    float: left; 
 
    width: 450px; 
 
    height: 630px; 
 
    border: 2px solid; 
 
    border-radius: 15px; 
 
} 
 

 
.container-inner { 
 
    border-radius: 15px; 
 
    background: #F05050; 
 
    text-align: center; 
 
    width: 450px; 
 
    height: 40px; 
 
    float: left; 
 
    border: 2px solid; 
 
} 
 

 
.container2 { 
 
    background-color: #ccc; 
 
    width: 650px; 
 
    margin-left: 780px; 
 
    margin-top: 30px; 
 
    font-size: 50px; 
 
    font-family: Courier New; 
 
    opacity: 0.7; 
 
    text-align: center; 
 
    border: dashed; 
 
} 
 

 
.bachelor { 
 
    font-size: 40px; 
 
    background-color: #ccc; 
 
    border: 2px solid; 
 
    width: 800px; 
 
    height: 100px; 
 
    margin-left: 710px; 
 
    margin-right: 650px; 
 
    text-align: center; 
 
    opacity: 0.6; 
 
    font-family: Courier New; 
 
    font-style: bold; 
 
}
<div class="top">Study in Czech Republic</div><br> 
 
<ul> 
 
    <li><a>Home</a></li> 
 
    <li><a>News</a></li> 
 
    <li><a>Czech Republic</a> 
 
    <ul> 
 
     <li><a>Facts and figures</a></li> 
 
     <li><a>Area</a></li> 
 
     <li><a>Climate</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a>Study</a> 
 
    <ul> 
 
     <li><a>How to apply</a></li> 
 
     <li><a>Programmes</a></li> 
 
     <li><a>Scholarships</a></li> 
 
     <li><a>Tuition fees</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a>Living</a> 
 
    <ul> 
 
     <li><a>Arrival</a></li> 
 
     <li><a>Living costs</a></li> 
 
     <li><a>Work</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a>Contact</a></li> 
 
</ul> 
 
<div class="container-inner">Why study in the Czech Republic</div><br><br> 
 
<div class="container">These days, over 37,000 foreign students are studying in the Czech Republic; and as their universities continue to offer a ton of English-taught courses, more and more students are finding interesting options there. But if you decide to go there, you’ll 
 
    find a large, exciting community of international students just like you. Universities in the Czech Republic also offer a wide range of programmes at the Bachelor’s, Master’s, and Ph.D level; and each university is accredited, meaning that their courses 
 
    are recognised by companies and organisations all over the country and throughout Europe. In the Czech Republic, you can find one of the oldest traditions of higher education, dating all the way back to the 14th century. It probably also means the universities 
 
    are haunted.</div> 
 
<div class="container2"> 
 
    EXPERIENCE STUDYING IN THE HEART OF EUROPE 
 
</div><br> 
 
<div class="bachelor">Bachelor's Degrees in Czech Republic</div>

+0

動作しません。 –

+0

正確に動作していないもののスクリーンショットを共有してください。また、どのように表示されるべきかを示すために2番目のスクリーンショットがさらに優れています。上記のスニペットは私にとってはうまくいくようです。 –

+0

ありがとうございました!それは働いた:) –

0

はこの1

からopacity: 0.8;を削除してみてくださいcontainer

ul li ul li

body { 
 
    font: 1.5em Arial; 
 
    background-image: url('prague2.jpeg'); 
 
    background-size: cover; 
 
} 
 

 
.top { 
 
    opacity: 0.8; 
 
    font-size: 65px; 
 
    font-family: Courier new; 
 
    text-align: center; 
 
    background: #EBA23C; 
 
    width: 100%; 
 
} 
 

 
ul { 
 
    float: right; 
 
    margin: 0px; 
 
    padding: 0px; 
 
    list-style: none; 
 
} 
 

 
ul li { 
 
    float: left; 
 
    width: 200px; 
 
    height: 40px; 
 
    background-color: #F05050; 
 
    text-align: center; 
 
    font-size: 20px; 
 
    line-height: 40px; 
 
    margin-right: 2px; 
 
} 
 

 
ul li a { 
 
    text-decoration: none; 
 
    color: white; 
 
    display: block; 
 
} 
 

 
ul li a:hover { 
 
    background-color: #C6AEF0; 
 
} 
 

 
ul li ul li { 
 
    display: none; 
 
    opacity: 0.9; 
 
} 
 

 
ul li:hover ul li { 
 
    display: block; 
 
} 
 

 
.container { 
 
    line-height: 35px; 
 
    font-style: Lucida Console; 
 
    font-size: 22px; 
 
    // opacity: 0.8; 
 
    background: #F0E3CA; 
 
    float: left; 
 
    width: 450px; 
 
    height: 630px; 
 
    border: 2px solid; 
 
    border-radius: 15px; 
 
} 
 

 
.container-inner { 
 
    border-radius: 15px; 
 
    background: #F05050; 
 
    text-align: center; 
 
    width: 450px; 
 
    height: 40px; 
 
    float: left; 
 
    border: 2px solid; 
 
} 
 

 
.container2 { 
 
    background-color: #ccc; 
 
    width: 650px; 
 
    margin-left: 780px; 
 
    margin-top: 30px; 
 
    font-size: 50px; 
 
    font-family: Courier New; 
 
    opacity: 0.7; 
 
    text-align: center; 
 
    border: dashed; 
 
} 
 

 
.bachelor { 
 
    font-size: 40px; 
 
    background-color: #ccc; 
 
    border: 2px solid; 
 
    width: 800px; 
 
    height: 100px; 
 
    margin-left: 710px; 
 
    margin-right: 650px; 
 
    text-align: center; 
 
    opacity: 0.6; 
 
    font-family: Courier New; 
 
    font-style: bold; 
 
}
<meta charset="utf-8"> 
 

 
<head> 
 
    <title>Home page</title> 
 
    <link rel="stylesheet" href="style.css"> 
 
    <div class="top">Study in Czech Republic</div><br> 
 
    <ul> 
 
    <li><a>Home</a></li> 
 
    <li><a>News</a></li> 
 
    <li><a>Czech Republic</a> 
 
     <ul> 
 
     <li><a>Facts and figures</a></li> 
 
     <li><a>Area</a></li> 
 
     <li><a>Climate</a></li> 
 
     </ul> 
 
    </li> 
 
    <li><a>Study</a> 
 
     <ul> 
 
     <li><a>How to apply</a></li> 
 
     <li><a>Programmes</a></li> 
 
     <li><a>Scholarships</a></li> 
 
     <li><a>Tuition fees</a></li> 
 
     </ul> 
 
    </li> 
 
    <li><a>Living</a> 
 
     <ul> 
 
     <li><a>Arrival</a></li> 
 
     <li><a>Living costs</a></li> 
 
     <li><a>Work</a></li> 
 
     </ul> 
 
    </li> 
 
    <li><a>Contact</a></li> 
 
    </ul> 
 
    <div class="container-inner">Why study in the Czech Republic</div><br><br> 
 
    <div class="container">These days, over 37,000 foreign students are studying in the Czech Republic; and as their universities continue to offer a ton of English-taught courses, more and more students are finding interesting options there. But if you decide to go there, you’ll 
 
    find a large, exciting community of international students just like you.

+0

は動作しません:( –

+0

'スニペット出力'は正しく動作していますか? – Bhargav

+0

スニペット出力では、背景の画像とコンテナが中央に表示されません –

関連する問題