CSSでスムーズなスクロール効果を作成するにはどうすればよいですか?
例
<!DOCTYPE html>
<html>
<head>
<style>
html {
scroll-behavior: smooth;
}
* {
box-sizing: border-box;
}
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
margin: 0px;
padding: 0px;
}
#firstSection {
height: 100vh;
background-color: rgb(119, 77, 219);
color: white;
padding: 20px;
}
#secondSection {
height: 100vh;
color: white;
background-color: rgb(42, 128, 168);
padding: 20px;
}
a {
text-decoration: none;
font-size: 20px;
font-weight: bold;
color: yellow;
}
</style>
</head>
<body>
<h1>Smooth Scroll Example</h1>
<div id="firstSection">
<h2>Section 1</h2>
<p>Click on the link to see the "smooth" scrolling effect.</p>
<a href="#secondSection">Click Here to Smooth Scroll to Section 2 Below</a>
</div>
<div id="secondSection">
<h2>Section 2</h2>
<a href="#firstSection">Click Me to Smooth Scroll to Section 1 Above</a>
</div>
</body>
</html> 出力
上記のコードは次の出力を生成します-
-
CSSで矢印を作成するにはどうすればよいですか?
CSSで矢印を作成するためのコードは次のとおりです- 例 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
-
CSSで視差スクロール効果を作成する方法
背景と前景のコンテンツに異なる速度を指定することで、CSSを使用して視差スクロール効果を作成できます。 次の例は、CSS視差スクロール効果-を示しています。 例 <!DOCTYPE html> <html> <head> <style> body, html { height: 100%; text-align: center; } .example { height: 100%; background-attachment: fixed;