如何使背景图像即使滚动也保持在左下角
我想知道是否有一种方法可以使我的背景图像始终保持在左下角,即使用户滚动浏览器也是如此。我当前的CSS可以在网站加载时使图像位于浏览器底部,但是如果我滚动浏览器,它仍然会停留在同一位置。我很感激任何帮助。
html, body
{
background-image:url("backgroundBottom.png");
background-position:bottom left;
background-repeat:no-repeat;
background-attachement:fixed; //I just add this, don't think this would work.
font-family:"Georgia, self";
font-size:"30px";
margin:0px;
height:100%;
text-align:center;
}
I was wondering if there is a way to keep my background image on bottom left all the time even if the user scroll the browser. My current css can make the image in the bottom of the browser when the site loaded, but if I scroll the browser, it will still stay in the same location. I appreciate any help.
html, body
{
background-image:url("backgroundBottom.png");
background-position:bottom left;
background-repeat:no-repeat;
background-attachement:fixed; //I just add this, don't think this would work.
font-family:"Georgia, self";
font-size:"30px";
margin:0px;
height:100%;
text-align:center;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您正在 HTML 和 HTML 上设置背景。身体元素。
代码看起来不错,background-attachment:fixed就是你所需要的。
所以在简写 CSS 中,只需写
You're setting the background on both the HTML & BODY elements.
The code looks good, background-attachment: fixed is what you need.
So in shorthand CSS, just write
如果它是一个没有重复的固定图像,我建议将它放在它自己的 div 标签中,该标签与图像的宽度和高度完全相同。
然后使用以下 CSS
显然是根据您的需求定制的
要点是
position:fixed
http://www.w3schools.com/Css/pr_class_position.asp
if it is a fixed image with no repeat, I would recommend putting it in it's own div tag that is exactly the same width and height as the image.
Then use the following CSS
obviously customized to your needs
The main point is
position:fixed
http://www.w3schools.com/Css/pr_class_position.asp
您使用了background-attach*e*ment:fixed;
尝试更好地拼写它,例如 background-attachment:fixed;
you used background-attach*e*ment:fixed;
try spelling it better like background-attachment:fixed;