문제

I am a novice at CSS/HTML and need help with a certain issue. I am trying to make my opening div (w/ background image) cover the entire screen (which I have done successfully). The problem is, no matter what I try, I cannot get the next div to start after the initial div. I am including my HTML and CSS. Problem is that I cannot cause #map-contain to start after #opening. Thought it would simply be 'positioning' issue but I cannot solve this. Please help. http://jsfiddle.net/nELQF/ - (need black div to start at bottom of red div)

HTML

<div id="opening">
</div>
<div id="map-section">
</div>

CSS

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    width: 100%;
}

#opening {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    border: 1px solid orange;
    background-image: url('DSC_0577.JPG');
    background-position: center;
    background-size: cover;
}

#map-section {
width: 100%;
height: 800px;
background-color: black;
}
도움이 되었습니까?

해결책

Given that the top element is absolutely positioned, you could do the same with the second element and set top:100% in order prevent the elements from overlapping.

Updated Example

#map-section {
    width: 100%;
    position: absolute;
    height: 800px;
    top: 100%;
    background-color: black;
}

As an alternative, an arguably better approach allowing you to avoid having to absolutely position both elements would be to simply set a height of 100% on the html/body elements.

Example Here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top