0

i waited for 7 days to ask this question because i can't ask more question, i want to keep the wrapper in the middle when people re-size the page

header {
    background-image: url("http://lorempixel.com/400/200");
    background-size: 100% 100%;
    height: 100px;
}
#home {
position:absolute;
top:10px;
left:400px;
}
<header>
 <img id="home" src="https://cdn2.iconfinder.com/data/icons/snipicons/5000/home-128.png" alt="home" style="width:75px;height:67px">
</header>

thnx

Heq Dz
  • 3
  • 1
  • 4
  • http://jsfiddle.net/6xaeej5f/ this is example u can see the "home" wrapper in the header keep going to the left when i try to re-size the page i want it to stay in the midle thanks – Heq Dz Jan 28 '15 at 02:34

3 Answers3

0

You could simply add text-align: center to the parent element. The img will respect this because it is inline by default.

Updated Example

header {
    background-image: url("http://lorempixel.com/400/200");
    background-size: 100% 100%;
    height: 100px;
    text-align: center;
}

See this answer for alternative approaches.

Community
  • 1
  • 1
Josh Crozier
  • 202,159
  • 50
  • 343
  • 273
0

That should do it, if all you need is keeping the icon centred all the time you don't really need to absolute position it.

header {
    background-image: url("http://lorempixel.com/400/200");
    background-size: 100% 100%;
    height: 100px;
    text-align: center;
}

#home {
   margin-top: 10px;
}
Karim Tarek
  • 599
  • 4
  • 14
0

try this,

#home {
position:absolute;
top:10px;
left:48%;
}
illusionist
  • 7,996
  • 1
  • 46
  • 63