I'm trying to horizontally center a DIV inside another DIV that has an image in it. I can get it to work with just a parent\child DIV, but as soon as I add the image things go crazy.
This is what I've tried. Ideally I would like box2 to be centered at the bottom of the outer DIV\image, but on TOP of the image, regardless of what size image is used.
see for example http://i60.tinypic.com/mbmqzr.jpg
Suggestions?
https://jsfiddle.net/uz0L5oow/2/
CSS
#box1{
position:relative;
display:inline-block;
width: 200px;
height: 200px;
}
#box2{
width:50px;
margin: 0 auto;
background-color: yellow;
}
HTML
<div id="box1">
<img src="http://i44.tinypic.com/2j4akqb.jpg"/>
<div id="box2">box</div>
</div>