responsive design - How to pin an image onto another image css -
i have code:
<body style="margin:0; padding:0;"> <div style="position: relative; left:0; top:0;"> <img src="images/fullscreen.png" style="max-width: 100%; width: 100%; height:auto; position: relative; top:0; left:0;"/> <img src="images/smaller_animated.gif" style="position:absolute; top:140px; left:458px;"/> </div> </body>
fullscreen.png large full screen image. made kind of responsive, if make browser width less doesn't scroll , instead resizes.
now have animated gif want place within area of fullscreen image. there large rectangle grey background within fullscreen image , want pin animated gif centre of space. works fine except when resize window, gif doesnt move/resize fullscreen image , moves outside rectangle background.
ive played around making absolute , relative dont seem getting close, ideas?
you can this:
html:
<div id="fullscreen" align="center"> <img class="center_image" src="images/smaller_animated.gif"/> </div>
css:
#fullscreen { background: url(images/fullscreen.png) red; background-size: 100% 100%; max-width: 100%; width: 100%; height: 100%; position: absolute; top: 0; left: 0; } .center_image { position: absolute; top: calc(50% - /* halve height of image */); height: /* height of image */; width: /* width of image */; }
Comments
Post a Comment