2016-10-13 61 views
0

我在容器中添加圖像在此之後,當我創建另一個DIV它相互重疊的,我想下面的div容器第二個div可見股利重疊與其他事業部

這是HTML

<header> 
    <div class="top_nav"> 

    </div> 
</header> 
    <div class="container"> 
    <img src="cover.jpg"> 
    <div id="short-des"> 

</div> 
</div> 
<div class="details"> 
</div> 

CSS

*{ 
    margin: 0; 
    padding: 0; 
} 

.top_nav{ 
    height: 80px; 
    width: 100%; 
    background: rgba(0,0,0,.5); 
    position: relative; 
} 

.container{ 
    height: 638px; 
    width: 100%; 
    max-width: 100%; 
    position: absolute; 
    overflow: hidden; 
    background-position: center; 
    top: 0; 
    z-index: -1; 
} 

.container img{ 
    width: 100%; 
    height: 638px; 
} 

.details{ 
    height: 638px; 
    width: 100%; 
    position: absolute; 

} 

我想div名稱的細節,以顯示div容器

+0

你給細節容器絕對位置,如果你移除它想要默認行爲 – Siddharth

回答

0

這裏下面是溶膠ution(fiddle):

*{ 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 

 
.top_nav{ 
 
    height: 80px; 
 
    width: 100%; 
 
    background: rgba(0,0,0,.5); 
 
    position: relative; 
 
} 
 

 
.container{ 
 
    height: 638px; 
 
    width: 100%; 
 
    max-width: 100%; 
 
    overflow: hidden; 
 
    background-position: center; 
 
    top: 0; 
 
    z-index: -1; 
 
} 
 

 
.container img{ 
 
    width: 100%; 
 
    height: 638px; 
 
    display: block; 
 
} 
 

 
.details{ 
 
    height: 638px; 
 
    width: 100%; 
 
}
<header> 
 
    <div class="top_nav"> 
 
     top nav 
 
    </div> 
 
</header> 
 
<div class="container"> 
 
    <img src="http://placehold.it/300x300"> 
 
    <div id="short-des"> 
 
     short descr 
 
    </div> 
 
</div> 
 
<div class="details"> 
 
    details 
 
</div>

+0

我給容器div的位置是絕對的,因爲我希望圖像從頂部開始看菜單欄 –

0

我想這是你想要fiddle

.container{ 
    height: 638px; 
    width: 100%; 
    max-width: 100%; 
    overflow: hidden; 
    background-position: center; 
    top: 0; 
    z-index: -1; 
} 
.details{ 
    height: 638px; 
    width: 100%; 
    border:solid 1px red; 
} 

去除的位置是什麼:絕對財產

+0

我給容器div的位置絕對,因爲我想要圖像從頂部開始查看菜單欄上我if刪除位置絕對它使我的圖像顯示在菜單欄 –

+0

或者你可以把圖像放在頂部吧?沒有? – Siddharth

+0

不知道爲什麼你想要這個,但你可以嘗試'position:relative'和'z-index'來將圖像放在菜單欄上。 –

0
<header> 
    <div class="container"> 
     <div class="top-nav"> 
     </div> 
    </div> 
</header> 


<section class="section-one"> 
    <div class="continer"> 
     <div class="image-outer"><img src="your-image"> 
     </div> 


     <div class="your-title"> 
     </div> 
    </div> 
</section> 
+0

這應該工作完美,如果你使用引導 –

+0

應該是

。也請格式化您的代碼。 – Roberrrt

+0

對不起,哥們,謝謝你的糾正 –