CSS background image on DIV's vertical center
I have a div and I need to get a small background image into the vertical cente开发者_如何转开发r of that DIV using CSS.
Can anyone help please?
Thanks.
To vertically center:
#con {
background: url(image.jpg) no-repeat left center;
}
To horizontally center:
#con {
background: url(image.jpg) no-repeat center top;
}
#somediv {
background: url (image.jpg) no-repeat 50% 50%;
}
the 50% centers it horizontally and vertically.. alternatively you can use center center
精彩评论