質問編集履歴

2

HTML・CSS・JSのコードを追記。

2022/05/19 02:51

投稿

yu62ballena
yu62ballena

スコア22

test CHANGED
File without changes
test CHANGED
@@ -11,5 +11,268 @@
11
11
  どんな問題が考えられるでしょうか?
12
12
  ご助力いただけると非常に助かります。
13
13
 
14
+ 以下に実際のコードを示します。
15
+
16
+ おおまかに言うと、画面が読み込まれたら#splashの部分を表示し、一定時間後にフェードアウトさせることで、メインコンテンツが表示されるという風にしています。
17
+ そのほか、グローバルメニューが順番に下からスライドしながらふわっと表示されるようにしています。
18
+
19
+
20
+ ```HTML
21
+ <!DOCTYPE html>
22
+ <html lang="ja">
23
+ <head>
24
+ <meta charset="UTF-8">
25
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
26
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
27
+ <link rel="preconnect" href="https://fonts.googleapis.com">
28
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
29
+ <link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,700;1,700&display=swap" rel="stylesheet">
30
+ <link rel="stylesheet" href="css/reset.css">
31
+ <link rel="stylesheet" href="css/style.css">
32
+ <title>my portfolio...</title>
33
+ </head>
34
+
35
+ <body>
36
+ <!-- 読み込み前 -->
37
+ <div id="splash">
38
+ <div class="hide-top-pictures">
39
+ <img class="pic01 hidden" src="image/top cage.jpg" alt="ケージの天井" width="350px" height="233px">
40
+ <img class="pic02 hidden" src="image/top flower.jpg" alt="花単体" width="253px" height="380px">
41
+ <img class="pic03 hidden" src="image/top sky.jpg" alt="空" width="300px" height="200px">
42
+ <img class="pic04 hidden" src="image/top mini building.jpg" alt="家" width="400px" height="266px">
43
+ <img class="pic05 hidden" src="image/top flowers.jpg" alt="花たち" width="280px" height="280px">
44
+ </div>
45
+ </div>
46
+ <div id="container">
47
+
48
+ <!-- ===============================
49
+ header ここから
50
+ ================================= -->
51
+ <header class="header">
52
+ <div class="wrapper">
53
+ <img class="logo" src="image/logo.png" alt="メインロゴ" width="150px" height="150px">
54
+ <nav class="global-nav">
55
+ <ul>
56
+ <li class="global-item hidden"><a href="index.html" class="global-link">Top</a></li>
57
+ <li class="global-item hidden"><a href="gallery.html" class="global-link">Gallery</a></li>
58
+ <li class="global-item hidden"><a href="about_me.html" class="global-link">About me</a></li>
59
+ <li class="global-item hidden"><a href="contact.html" class="global-link">Contact</a></li>
60
+ </ul>
61
+ </nav>
62
+ </div>
63
+ </header>
64
+
65
+
66
+ <!-- ===============================
67
+ main ここから
68
+ ================================= -->
69
+ <main class="main">
70
+ <!-- タイトル -->
71
+ <div class="descriptions">
72
+ <h1 class="site-title textRandomAnime">my portfolio...</h1>
73
+ <p class="explanation">all of my works are here</p>
74
+ <!-- <div class="white-title"></div> -->
75
+ </div>
76
+
77
+ <!-- 写真 -->
78
+ <div class="top-pictures">
79
+ <img class="pic01" src="image/top cage.jpg" alt="ケージの天井" width="350px" height="233px">
80
+ <img class="pic02" src="image/top flower.jpg" alt="花単体" width="253px" height="380px">
81
+ <img class="pic03" src="image/top sky.jpg" alt="空" width="300px" height="200px">
82
+ <img class="pic04" src="image/top mini building.jpg" alt="家" width="400px" height="266px">
83
+ <img class="pic05" src="image/top flowers.jpg" alt="花たち" width="280px" height="280px">
84
+ </div>
85
+ </main>
86
+ </div>
87
+
88
+
89
+ <!-- ===============================
90
+ script ここから
91
+ ================================= -->
92
+ <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
93
+ <script src="js/script.js"></script>
94
+ </body>
95
+ </html>
96
+ ```
97
+
98
+ ```CSS
99
+ @charset "UTF-8";
100
+
101
+ html{
102
+ font-size: 62.5%;
103
+ }
104
+
105
+ *, *::before, *::after{
106
+ box-sizing: border-box;
107
+ }
108
+
109
+ body{
110
+ color: #666;
111
+ font-size: 1.6rem;
112
+ font-family: 'Cormorant Garamond', serif;
113
+ }
114
+
115
+ .main{
116
+ width: 100%;
117
+ }
118
+
119
+ /* ===============================
120
+ jQuery共通
121
+ ================================= */
122
+ .hidden{
123
+ opacity: 0;
124
+ transform : translateY(50px);
125
+ /* transform: translateY(20px); */
126
+ transition: all 1s;
127
+ }
128
+ .fadeup{
129
+ transform: translateY(0);
130
+ opacity: 0.8;
131
+ }
132
+
133
+ /* ===============================
134
+ 画面読み込み前処理
135
+ ================================= */
136
+ #splash {
137
+ position: fixed;
138
+ width: 100%;
139
+ height: 100%;
140
+ z-index: 998;
141
+ background:#fff;
142
+ }
143
+ #container{
144
+ width:100%;
145
+ height: 100vh;
146
+ }
147
+
148
+ /* ===============================
149
+ header ここから
150
+ ================================= */
151
+ .wrapper{
152
+ display: flex;
153
+ justify-content: space-between;
154
+ width: 100%;
155
+ padding: 0px 70px;
156
+ }
157
+ .global-nav{
158
+ padding-top: 55px;
159
+ }
160
+ .global-item{
161
+ display: inline-block;
162
+ margin-left: 20px;
163
+ list-style: none;
164
+ }
165
+ .global-link{
166
+ text-decoration: none;
167
+ font-size: 2.5rem;
168
+ color: #666;
169
+ transition: 0.4s;
170
+ padding-bottom: 3px;
171
+ }
172
+ .logo{
173
+ margin-top: 40px;
174
+ opacity: 0.8;
175
+ }
176
+ .global-item a::after{
177
+ content: '';
178
+ display: block;
179
+ width: 0;
180
+ margin: 6px auto 0;
181
+ border-bottom: 1px solid #666;
182
+ transition: width 0.1s ease-in-out;
183
+ }
184
+ .global-item a:hover::after{
185
+ width: 100%;
186
+ opacity: 0.5;
187
+ }
188
+ .global-item a:hover{
189
+ opacity: 0.5;
190
+ }
191
+
192
+
193
+
194
+ /* ===============================
195
+ index ここから
196
+ ================================= */
197
+ /* タイトル */
198
+ .descriptions{
199
+ position: relative;
200
+ top: 170px;
201
+ left: 200px;
202
+ }
203
+ .site-title{
204
+ font-size: 10rem;
205
+ font-weight: bold;
206
+ z-index: 999;
207
+ margin-bottom: 30px;
208
+ letter-spacing: 1px;
209
+ }
210
+ .explanation{
211
+ font-size: 3rem;
212
+ }
213
+
214
+
215
+ /* 写真 */
216
+ .top-pictures{
217
+ opacity: 0.5;
218
+ }
219
+ .pic01{
220
+ position: absolute;
221
+ top: 180px;
222
+ left: 300px;
223
+ }
224
+ .pic02{
225
+ position: absolute;
226
+ top: 90px;
227
+ left: 800px;
228
+ }
229
+ .pic03{
230
+ position: absolute;
231
+ top: 310px;
232
+ left: 1200px;
233
+ }
234
+ .pic04{
235
+ position: absolute;
236
+ top: 570px;
237
+ left: 900px;
238
+ }
239
+ .pic05{
240
+ position: absolute;
241
+ top: 620px;
242
+ left: 480px;
243
+ }
244
+
245
+ ```
246
+
247
+ ```JS
248
+ $(function(){
249
+
250
+ $(window).on('load',function(){
251
+
252
+ $('#splash .hide-top-pictures img').each(function(index){
253
+
254
+ let $this = $(this);
255
+ delayTime = index;
256
+
257
+ setTimeout(function(){
258
+ $this.addClass('fadeup');
259
+ }, 300 * delayTime);
260
+ });
261
+
262
+
263
+ $('.global-nav .global-item').each(function(index){
264
+
265
+ let $this = $(this);
266
+ delayTime = index;
267
+
268
+ setTimeout(function(){
269
+ $this.addClass('fadeup');
270
+ }, 1600 + (300 * delayTime));
271
+ });
272
+
273
+ $("#splash").delay(1500).fadeOut(1000);
274
+ });
275
+ });
276
+ ```
14
277
  よろしくお願いいたします。
15
278
 

1

リロードした際の情報を追記しました。

2022/05/19 02:24

投稿

yu62ballena
yu62ballena

スコア22

test CHANGED
File without changes
test CHANGED
@@ -6,6 +6,7 @@
6
6
  HTMLのファイルを右クリックし「プログラムから開く」でブラウザで開くと、javascriptが反映されなくなってしまうのです。
7
7
 
8
8
  HTMLとCSSは毎回正しく開けており、javascriptだけうまく読み込めないことが多いようです。
9
+ リロードを繰り返すと1割くらいの確率で読み込むことがあります。
9
10
 
10
11
  どんな問題が考えられるでしょうか?
11
12
  ご助力いただけると非常に助かります。