2016-10-13 63 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

对不起,哥们,谢谢你的纠正 –