html - How to make image position absolute relative to another image? -
#main { border: 2px blue solid; width: 100%; } #photo { display:flex; align-items: center; justify-content: center; } #photo > #large { width:70%; margin: 20px 0px; border: 3px red solid; } #small { position: absolute; width:150px; left:0px; }
<div id="main"> <div id="photo"> <img src="image/test.jpg" id="large"> <img src="image/sale.jpg" id="small"> </div> </div>
above code, want large image centre in photo div , small image set absolute , relative large image.
how can that?
now small image relative main div.
you need use div here.
#main { border: 2px blue solid; width: 100%; } #photo { display:flex; align-items: center; justify-content: center; } #photo > #photo-center { width:70%; position:relative; margin: 20px 0px; border: 3px red solid; } #large{ width:100%; } #small{ width:150px; position:absolute; left:0; top:0; z-index:1; }
<div id="main"> <div id="photo"> <div id="photo-center"> <img src="http://blog.jimdo.com/wp-content/uploads/2014/01/tree-247122.jpg" id="large"> <img src="http://www.hdwallpapersimages.com/wp-content/uploads/2014/01/winter-tiger-wild-cat-images.jpg" id="small"> </div> </div> </div>
Comments
Post a Comment