Reputation: 47945
My scenario:
div
of size 200 x 150 pixels.I have resized the image using the following CSS:
max-width:300px;
max-height:300px;
The height will be kept in proportion, so in this example it will be 252 px.
How can I center the image in the div
? I mean something like:
background-position: center center;
Is this sort of thing possible with CSS 2?
Upvotes: 0
Views: 120
Reputation: 480
To center the DIV within an element, you would set a width
and margin
with the left and right margins set to auto:
div {
margin: 0 auto;
width: 300px;
}
Upvotes: 0
Reputation: 3335
You mean
background:url("test.png");
background-size: 300px auto;
background-position: center center;
?
Upvotes: 2