繁体   English   中英

完全向下滚动时固定背景图像

[英]fixate background image when fully scrolled down

我有这个页面:

在此处输入图片说明

它有一个背景图像,可以向下滚动:

在此处输入图片说明

不幸的是,一旦整个图像滚动通过它要么重复要么启用no-repeat时,就会被切断而根本没有图像:

在此处输入图片说明

完全向下滚动时如何固定背景图像?

编辑:

我对自己想要什么还不够清楚。 我希望此设置从scroll更改为fixed和返回,具体取决于图像是否完全滚动:

/*as long as image can be scrolled and does not reach its end/repeats*/
body {background-attachment: "scroll";}

<->

/*if end of image reached/repeats*/
body {background-attachment: "fixed";}

您应该遵循 CSS 相同

background: url(images/bg.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;

要么

background-size: 100% 100%;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM