【发布时间】:2018-08-12 04:40:21
【问题描述】:
我尝试为具有固定位置的无限水平滚动图案/图像提供功能(见下文)。无限滚动功能有效,但我唯一的问题是固定位置。
我想给无限的水平滚动图像一个固定的位置,这意味着如果我向下滚动网站,图像应该保持在原位并且应该同时水平滚动。
我尝试在 css 类选择器下添加 "position:fixed;" 或 "background-attachment: fixed",但它不起作用,而不是正常工作,图像消失了。
网址:https://codepen.io/Founts/pen/dXkyAa
.hero {
height: 300px;
}
.hero-img {
background: transparent url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/50859/bit-tile-blue.gif) repeat-x 50% 0;
animation: infinite-shift-left 5000s linear;
}
@keyframes infinite-shift-left {
0% {
background-position: 50000px;
}
100% {
background-position: 0;
}
}
<div class="hero hero-img">
</div>
【问题讨论】:
标签: html css css-animations