個人而言,我會建議使用在標題
這裏一個梯度小提琴證明:https://jsfiddle.net/ve806t1a/
這裏是我使用的代碼:
<p class="header">
HEADER
</p>
<div class="header-bg"></div>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
<p>
CONTENT
</p>
CSS:
* {
margin: 0;
padding: 0;
}
body {
background-color: rgba(198, 115, 115, 1);
}
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 20;
background-color: rgba(198, 115, 115, 1);
}
.header-bg {
position: fixed;
top: 50px;
left: 0;
height: 100px;
width: 100%;
background-image:linear-gradient(rgba(198, 115, 115, 1),rgba(47, 52, 172, 0));
}
p {
text-align: center;
padding: 20px 0;
}
這是做一個真正的好辦法!刪除我的答案 – Jesus
乾杯瑞恩 - 保持你的,但我會好奇,看看你的作品。我的背景圖片等效果不好,所以如果你有一個更長,但更強大的解決方案,看起來很酷。 –
@FraserBenjamin這個想法是對的,但我需要頁眉/頁腳沒有自己的背景,因爲你的只能使用平坦的背景。 – genesi5