【发布时间】:2017-02-08 20:44:51
【问题描述】:
我正在尝试在 div 的左上角添加一个图像“条”作为具有固定附件属性的背景。这里是: https://jsfiddle.net/mvfariajr/recLr6yf/
HTML:
<div id="wrapper">
<div id="container">
<h1>TESTING</h1>
</div>
</div>
CSS:
#wrapper {
width: 100%;
height: 500px;
background-color: #ccc;
}
#container {
text-align: center;
margin: 0 auto;
width: 80%;
height: 400px;
background-color: #fff;
background-position: left top;
background-repeat: no-repeat;
background-size: 70px 100%;
background-attachment: fixed;
background-image: url(http://ariseartgroup.com/interiors/wp-content/uploads/2017/01/metal-texture-trim.jpg);
}
问题是背景并不总是在 div 的左侧。
有什么帮助吗? 谢谢!
【问题讨论】:
-
你是否试图只运行图像从上到下而不重复
-
可以,但属性固定。
-
@MichaelCoker 你的结果和我的没有区别。我正在尝试拥有一个固定的附件属性 + 一个 70 像素的固定宽度,左上角定位。
-
@Marcio 抱歉,我在开发工具中进行了更改,但没有更新小提琴! jsfiddle.net/recLr6yf/3
-
它在我的网站上仍然无法正常工作。看看这个:ariseartgroup.com/interiors/about
标签: html css background-image css-position