teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

説明追記

2021/04/19 02:36

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -10,118 +10,17 @@
10
10
 
11
11
  absoluteやfixedの設定を外せばCSSはシンプルになります。
12
12
 
13
+ 追記
14
+ ---
15
+ サンプル作成している間に自己解決したのですね。
16
+ 自己解決のコードをみてやっとやりたいことが理解できました。
13
17
 
14
- absoluteやfixedやめて、gridレイアウトを活かしたド例
18
+ 複数の背景画像固定したまま、スクロルで切り替えたいということですね。
15
19
 
20
+ 質問のコードには背景画像が一つしかなかったので、そこまで推測できませんでした。
16
21
 
17
- ```css
22
+ サンプルを書き直しました。ご参考になれば。
18
23
 
19
- /* container
20
- --------------------------------------------------------- */
21
- .container {
22
- display: grid;
23
- grid-template-columns: 8fr 26fr;
24
- animation: fadeIn 3s ease 0s 1 normal;
24
+ absoluteやfixedをやめて、gridレイアウトを活かしたコード例
25
- height: 100vh;
26
- }
27
- @keyframes fadeIn {
28
- from {
29
- opacity: 0;
30
- }
31
- to {
32
- opacity: 1;
33
- }
34
- }
35
- .container-right {
36
- background-color: #f6f6f6;
37
- color: #024058;
38
- }
39
- /* guide
40
- --------------------------------------------------------- */
41
- .guide {
42
- display: grid;
43
- grid-template-rows: 13fr 8fr;
44
- place-items: center;
45
- }
46
- .face {
47
- margin: 0 auto;
48
- min-width: 100%;
49
- max-width: 224px;
50
- }
51
- .face img {
52
- border-radius: 50%;
53
- }
54
- .name {
55
- font-family: serif;
56
- letter-spacing: 0.1em;
57
- text-align: center;
58
- ruby-position: under;
59
- }
60
- .name rt {
61
- font-size: 8px;
62
- letter-spacing: 1em;
63
- opacity: 0.5;
64
- }
65
- .global-nav {
66
- align-self: start;
67
- }
68
25
 
69
- .nav-menu a {
70
- font-family: serif;
71
- font-size: 24px;
72
- position: relative;
73
- }
74
- .nav-menu a:hover {
75
- opacity: 1;
76
- }
77
- .nav-menu a::after {
78
- content: "";
79
- position: absolute;
80
- bottom: -4px;
81
- left: 0;
82
- width: 100%;
83
- height: 2px;
84
- background-color: #fff;
85
- transform: scale(0, 1);
86
- transform-origin: center top;
87
- transition: transform 250ms;
88
- }
89
- .nav-menu a:hover::after {
90
- transform: scale(1, 1);
91
- }
92
-
93
- /* profile
94
- --------------------------------------------------------- */
95
- .profile {
96
- height: 100%;
97
- background-image: url(https://placehold.jp/2048x1364.png);
98
- background-attachment: scroll;
99
- background-position: center;
100
- background-size: cover;
101
- background-repeat: no-repeat;
102
- overflow-y: scroll;
103
- }
104
- .parallax {
105
- height: 100%;
106
- }
107
- .parallax h2 {
108
- color:#fff;
109
- font-family: Quicksand;
110
- font-size: 80px;
111
- text-shadow: 0px 0px 10px #c0c0c0;
112
- text-align: center;
113
- position: relative;
114
- top: 20%;
115
- }
116
- .contents {
117
- z-index: 1;
118
- height:500px;
119
- font-size:60px;
120
- background: #f89174;
121
- padding: 100px 20px;
122
- text-align :center;
123
- }
124
-
125
- ```
126
-
127
26
  [CodePenサンプル](https://codepen.io/hatena19/pen/gOgdLxp?editors=0100)