开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜