如果你想使用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