Reputation: 49422
I have a div and I need to get a small background image into the vertical center of that DIV using CSS.
Can anyone help please?
Thanks.
Upvotes: 31
Views: 46910
Reputation: 92853
To vertically center:
#con {
background: url(image.jpg) no-repeat left center;
}
To horizontally center:
#con {
background: url(image.jpg) no-repeat center top;
}
Upvotes: 50
Reputation: 27664
#somediv {
background: url (image.jpg) no-repeat 50% 50%;
}
the 50% centers it horizontally and vertically.. alternatively you can use center center
Upvotes: 11