如果你想使用CSS3渐变做到这一点,请尝试添加以下内容到选择器。
因此,例如,如果您将渐变应用于#background
,则将其添加到CSS渐变之后。 重要:您必须在后台属性之后添加此项。
background-attachment: fixed;
w3schools.org: CSS background-attachment property
你的整个代码可能看起来像:
#background {
background: #1e5799;
background: -moz-linear-gradient(top, #1e5799 0%, #7db9e8 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8));
background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: -ms-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: linear-gradient(to bottom, #1e5799 0%,#7db9e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0);
background-attachment: fixed;
}
你提到的”最好的,我实际上能够做的是让渐变横跨整个连续而不仅仅是可见部分。“你是怎么做到的?这正是我需要的。” – RockPaperLizard