Sunday, October 12, 2014

Images in DIV

I;ve always had problems placing images in the div elements. its' not that i cannot place an img inside a div element.. it's hard to place it at the right position. But ive' come across this interesting trick which has been kind of a revelation for me..

http://jsfiddle.net/y6a7xqqj/

Try out the above jsfiddle test i created. It's amazing how flexible it is.

    background-position: 50% 50%


There is a short hand representation for all the properties that are covered by background..

background: url('urltoimg') no-repeat 50% 50%

This is the most beautiful thing ive' come across for positioning an image. You should be able to center the image where ever you feel like. 
Post a Comment