複数のシャドウエフェクトを試す
このステップでは、複数のボックスシャドウを使って複雑な影効果を作成する高度な技術を探ります。WebIDE で index.html ファイルを開き、以下のコードでその内容を更新します。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Multiple Shadow Effects</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
.card {
width: 300px;
height: 400px;
background-color: white;
border-radius: 10px;
/* 複数の影効果 */
box-shadow:
/* 外側の影 */
0 10px 20px rgba(0, 0, 0, 0.1),
/* 内側の影 */ inset 0 -5px 10px rgba(0, 0, 0, 0.05),
/* 色付きの強調影 */ 0 15px 25px rgba(0, 123, 255, 0.2);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 20px;
transition: transform 0.3s ease;
}
.card:hover {
transform: scale(1.05);
box-shadow:
0 15px 30px rgba(0, 0, 0, 0.2),
inset 0 -5px 10px rgba(0, 0, 0, 0.1),
0 20px 35px rgba(0, 123, 255, 0.3);
}
</style>
</head>
<body>
<div class="card">
<h2>Shadow Experiment</h2>
<p>Hover to see shadow effect!</p>
</div>
</body>
</html>
複数の影効果の重要な技術:
- 重ねた影:
- 最初の影:外側の柔らかい影
- 2 番目の影:内側の微妙な影
- 3 番目の影:色付きの強調影
- 影の構成:
0 10px 20px rgba(0, 0, 0, 0.1):柔らかい外側の影
inset 0 -5px 10px rgba(0, 0, 0, 0.05):内側の微妙な影
0 15px 25px rgba(0, 123, 255, 0.2):青の強調影
- ホバー効果:
- ホバー時に影の強さを増やす
- インタラクティブな感じを与えるために拡大変換を追加する
例の視覚的な出力:
+------------------------+
| |
| [Card with Complex |
| Shadow Effects] |
| |
+------------------------+
重要なポイント:
- 深さを表現するために複数の影を組み合わせる
- 内側の影には
inset を使用する
- ホバーでインタラクティブな効果を作成する