html - DIV 垂直居中的 CSS 背景图片

标签 html css

我有一个 div,我需要使用 CSS 将一个小背景图像放到该 DIV 的垂直中心。

有人可以帮忙吗?

谢谢。

最佳答案

垂直居中:

#con {
    background: url(image.jpg) no-repeat left center;
}

水平居中:

#con {
    background: url(image.jpg) no-repeat center top;
}

关于html - DIV 垂直居中的 CSS 背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5676197/

相关文章:

css - HTML/CSS 的常规屏幕 px 宽度标准

javascript - 当它的父级被创建为.empty() 时,如何获取从 DOM 中删除的 div?

javascript - 没有库的等效代码

css - 使用表行上的边框半径圆 Angular ,两个单元格在单元格边框处断开

javascript - 检测各种线路的末端谁不保持固定?

html - 无法单击 Chrome/Firefox/Safari 中较低 z-index 元素中的链接

html - name.html.erb 和 name.erb 的区别

css - 使用 div 标签定位元素

css - 与 LESS 相比,Stylus 中的 DRY 原则

html - 图片似乎没有以移动设备为中心