How to make an image center (vertically & horizontally) inside a bigger div

Personally, I’d place it as the background image within the div, the CSS for that being:

#demo {
    background: url(bg_apple_little.gif) no-repeat center center;
    height: 200px;
    width: 200px;
}

(Assumes a div with id="demo" as you are already specifying height and width adding a background shouldn’t be an issue)

Let the browser take the strain.

Leave a Comment