I have a image container(a div) with a set width and height.
now I got an image url from the backend and I need to put it in the container.
when the image is smaller than the container, I need to enlarge it to fullfill the container
when the image is bigger than the container, I need to center it in the container.
could this be done in pure CSS? or do I need to use JavaScript to do something?
You will need a mixture of css and javascript, here’s an example I’ve created for you:
http://jsfiddle.net/7fUxw/1/