CSSで背景の添付ファイルを設定する
background-attachmentを設定するには、background-attachmentプロパティを使用します。背景の添付ファイルは、背景画像を固定するか、ページの残りの部分と一緒にスクロールするかを決定します。
例
次のコードを実行して、background-attachmentプロパティを操作して固定の背景画像を設定する方法を学ぶことができます。
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('/css/images/css.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
</style>
</head>
<body>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
</body>
</html> -
CSSを使用して背景画像として線形グラデーションを設定します
linear-gradient()CSS関数を使用して、背景画像として線形グラデーションを設定します。次のコードを実行して、CSSでlinear-gradient()関数を実装してみてください 例 <!DOCTYPE html> <html> <head> <style> #demo { height: 200px;
-
CSSを使用して背景画像として放射状グラデーションを設定します
Radial-gradient()CSS関数を使用して、背景画像として放射状グラデーションを設定します。次のコードを実行して、CSSでlinear-gradient()関数を実装してみてください 例 <!DOCTYPE html> <html> <head> <style> #demo { height: 200px;