【发布时间】:2016-04-17 21:50:46
【问题描述】:
我有两个 div - 一个固定在页面左侧作为侧导航,另一个我有一个背景图像,我希望它是流动的,并覆盖 div 的宽度。我看了看,找不到任何像我要找的东西那样具体的东西。下面是我的代码。
.geodeticContainer {
width: 100%;
min-width: 800px;
}
.content {
width: 100%;
box-sizing: border-box;
margin-left: 300px;
}
.image {
width: 100%;
background-image: url("images/geodetics.jpg") norepeat center center fixed;
z-index:999;
}
.description {
position: fixed;
width: 300px;
height: 100%;
background-color: #eaeaed;
padding: 20px;
color: #0072bc;
}
<div class="geodeticContainer">
<div class="description">
This is the content of the side bar. There will be a descriptive paragraph about the image on the right hand side.
</div>
<div class="content">
<div class="image"></div>
</div>
</div>
如果已经完成,我很抱歉,但我找不到它,因为我不知道如何描述我在寻找什么。感谢我能得到的任何帮助。
【问题讨论】:
-
您的问题是什么?您的预期输出是什么。
-
这是您正在寻找的规则吗?
.content { background-size: cover; } -
我希望背景图像是右侧 div 宽度的 100%,但我似乎无法使用 css 规则“背景图像”显示它。 .content { background-size: cover;} 对我不起作用,我使用的是 chrome?我可以使图像显示在 HTML 中,但无法控制它对站点的响应。给你一个想法,img im使用的是1024 x 2452
-
您希望背景图片仅位于内容区域(非侧边栏)还是整个页面?
-
只是内容区域。
标签: css background-image css-position