【发布时间】:2013-08-21 16:29:04
【问题描述】:
有两个 div 类:一个 bar 嵌套了一个 menu
background-image 在放置在 bar 类中时没有正确缩放或响应,并且在放置在 menu 类中时没有出现,在该类中似乎适合响应式样式。
此外,图像是 png,但在空白空间中呈现为空白……为什么会这样?
现在都作为内联样式进行测试,但是,在嵌套在“css”文件夹中的外部样式表中,如何将图像指向与“css”文件夹路径相邻的“img”文件夹中?
为了响应性……背景图像应根据浏览器的高度/宽度进行缩放……
当前的 CSS:
.bar {
position: static;
bottom: 0;
height: 10%;
width: 100%;
display: block;
margin: 0 auto;
text-align: center;
}
.menu {
display: inline-block;
background-image: url("img/menu-bar.png");
}
【问题讨论】:
-
“不起作用”是一个非常宽泛的术语。 究竟是什么不起作用 - 请更详细地解释您的问题
-
背景尺寸:封面????
-
您确定背景图片的路径正确吗?这通常是缺少背景图片的问题。
-
确保 background-image url 是相对于 css 的,而不是你包含 css 的页面。Partial URLs are interpreted relative to the source of the style sheet, not relative to the document
-
好的,所以它部分是“相对于 css”的问题。将样式移到文档中,它在 'bar' 类中工作,但它的大小不合适......而且不是在“菜单”类中工作,这可能是它可以做出响应的地方..
标签: html css background-image