是否有可能为div
制作background-attachment:fixed;
定位div
的位置不带有视口?如果没有,也许还有其他的选择?是否可以定位background-attachment:相对于div而不是视口固定?
CSS
.zest-ghost {
width: 302px;
height: 222px;
top: 0;
left: 50%;
background-image: url(../images/logo-ghost.png);
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
HTML
<div class="zest-ghost"></div>
该代码使得图像
fixed
相对视口,而不是与div
。 I 需要相同的效果,但可以将图像左移或右移 。图像应该有它的原始宽度和高度
向我们展示你有试过吗? –
Theres没有mutch显示..我可以问为什么我得到消极? .. :) – Giedidius
我相信你被拒绝投票了,因为下来的选民并没有意识到你正在谈论'background-attachment'属性,因为你只是要求某些东西是'固定'的。我认为,你不想让div内的背景移动,这并不是那么微不足道。 – entwicklerseite