Simply change your CSS like this:
html, body {
width:100%;
height: 100%;
margin: 0;
}
#header {
overflow: hidden;
width:100%;
height: 100%;
background: orange;
background-size:cover;
-webkit-background-size:cover;
}
#wrap {
height: 200px;
width: 500px;
background:white;
margin:0px auto;
position:absolute;
top:50%;
left:50%;
margin-top:-100px;
margin-left:-250px;
}
html, body {
width:100%;
height: 100%;
margin: 0;
}
#header {
overflow: hidden;
width:100%;
height: 100%;
background: orange;
background-size:cover;
-webkit-background-size:cover;
}
#wrap {
height: 200px;
width: 500px;
background:white;
margin:0px auto;
position:absolute;
top:50%;
left:50%;
margin-top:-100px;
margin-left:-250px;
}
<div id="header">
<div id="wrap">
<h1>Header</h1>
<div id="some-text">Some text some text some text some text</div>
</div>
</div>
See fiddle here
Explanation:
This is one of the most common and oldest approaches to absolute centering elements with CSS when using fixed width elements. It simply consists in applying a position:absolute
to the element and a top and left 50%
value. While this sounds as it should work by itself, the element has properties of its own, such as width and height, so we need to apply a margin-left
and margin-top
equal to half of the size of the element (in this particular case, 100px and 250px)