質問編集履歴

1

コードを追加しました

2017/07/14 13:00

投稿

sutosi
sutosi

スコア27

test CHANGED
File without changes
test CHANGED
@@ -5,3 +5,929 @@
5
5
  スクリーンショットのようにページ上部をきれいに固定するにはどうしたらよろしいでしょうか。
6
6
 
7
7
  ご教授お願いいたします。
8
+
9
+
10
+
11
+ HTML
12
+
13
+ ```
14
+
15
+ <!DOCTYPE html>
16
+
17
+ <html lang="ja">
18
+
19
+ <head>
20
+
21
+ <meta charset="utf-8">
22
+
23
+ <link rel="stylesheet" href="css/font-awesome.min.css">
24
+
25
+ <!--インストールしたfontawesomeを読み込む-->
26
+
27
+ <link rel="stylesheet" href="css/styles.css">
28
+
29
+ <!--作ったCSSを読み込む-->
30
+
31
+ <meta bane="viewport" content="width=device-width, initial-scale=1.0">
32
+
33
+ <!--スマホで開いたとき度の幅で描画するかの設定-->
34
+
35
+ <title>nitta</title>
36
+
37
+
38
+
39
+ </head>
40
+
41
+
42
+
43
+ <body>
44
+
45
+
46
+
47
+ <div class="top">
48
+
49
+ <ul class="menu" >
50
+
51
+ <!-- <li>PROFILE</li>-->
52
+
53
+ <!-- <li>GRAPHIC</li>-->
54
+
55
+ <!-- <li>MUSIC</li>-->
56
+
57
+ <!-- <li>CONTACT</li>-->
58
+
59
+
60
+
61
+ <!-- -->
62
+
63
+ <a href="#contact" class="btn">
64
+
65
+ CONTACT
66
+
67
+ </a>
68
+
69
+ <a href="#music" class="btn">
70
+
71
+ MUSIC
72
+
73
+ </a>
74
+
75
+ <a href="#graphics" class="btn">
76
+
77
+ GRAPHICS
78
+
79
+ </a>
80
+
81
+ <a href="#profile" class="btn">
82
+
83
+ PROFILE
84
+
85
+ </a><!-- このhrefで指定したものを別のとこのid=""で指定してジャンプする-->
86
+
87
+ </ul>
88
+
89
+ <p><img src="img/rogo.png"></p><!--ロゴ-->
90
+
91
+ </div>
92
+
93
+
94
+
95
+ <header>
96
+
97
+
98
+
99
+ <section class="icon">
100
+
101
+ <p><img src="img/profile.png"></p>
102
+
103
+ </section>
104
+
105
+
106
+
107
+ <section class="profile">
108
+
109
+ <h2 id="profile">PROFILE</h2><!--ここでidを指定し、メニューから移動する-->
110
+
111
+ <div class="photo-show">
112
+
113
+ <img src="img/pro1.jpg">
114
+
115
+ <img src="img/pro2.jpg">
116
+
117
+ <img src="img/pro3.jpg">
118
+
119
+ <img src="img/pro4.jpg">
120
+
121
+ </div>
122
+
123
+ <div class="text">
124
+
125
+ <p>自転車に乗ったり音楽やったりデザインをしています。</p>
126
+
127
+ </div>
128
+
129
+ </section>
130
+
131
+
132
+
133
+ <section class="gra"><!--section2-->
134
+
135
+ <h2 id="graphics">GRAPHICS</h2>
136
+
137
+ <div class="container">
138
+
139
+ <div class="item">
140
+
141
+ <img src="img/gra1.jpg">
142
+
143
+ <p>hello. hello. hello. hello.</p>
144
+
145
+ </div>
146
+
147
+
148
+
149
+ <div class="item">
150
+
151
+ <img src="img/gra2.jpg">
152
+
153
+ <p>hello. hello. hello. hello.</p>
154
+
155
+ </div>
156
+
157
+
158
+
159
+ <div class="item">
160
+
161
+ <img src="img/gra3.jpg">
162
+
163
+ <p>hello. hello. hello. hello.</p>
164
+
165
+ </div>
166
+
167
+
168
+
169
+ </div>
170
+
171
+
172
+
173
+ <div class="container">
174
+
175
+ <div class="item">
176
+
177
+ <img src="img/gra1.jpg">
178
+
179
+ <p>hello. hello. hello. hello.</p>
180
+
181
+ </div>
182
+
183
+
184
+
185
+ <div class="item">
186
+
187
+ <img src="img/gra2.jpg">
188
+
189
+ <p>hello. hello. hello. hello.</p>
190
+
191
+ </div>
192
+
193
+
194
+
195
+ <div class="item">
196
+
197
+ <img src="img/gra3.jpg">
198
+
199
+ <p>hello. hello. hello. hello.</p>
200
+
201
+ </div>
202
+
203
+
204
+
205
+ </div>
206
+
207
+
208
+
209
+ <div class="container">
210
+
211
+ <div class="item">
212
+
213
+ <img src="img/gra1.jpg">
214
+
215
+ <p>hello. hello. hello. hello.</p>
216
+
217
+ </div>
218
+
219
+
220
+
221
+ <div class="item">
222
+
223
+ <img src="img/gra2.jpg">
224
+
225
+ <p>hello. hello. hello. hello.</p>
226
+
227
+ </div>
228
+
229
+
230
+
231
+ <div class="item">
232
+
233
+ <img src="img/gra3.jpg">
234
+
235
+ <p>hello. hello. hello. hello.</p>
236
+
237
+ </div>
238
+
239
+
240
+
241
+ </div>
242
+
243
+
244
+
245
+ </section>
246
+
247
+
248
+
249
+ <section class="music">
250
+
251
+ </section>
252
+
253
+
254
+
255
+ <section class="music">
256
+
257
+ <h2 id="music">MUSIC</h2>
258
+
259
+ <div class="music-container">
260
+
261
+ <div class="music-wrapper">
262
+
263
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/nul4IXdX8HE" frameborder="0" allowfullscreen></iframe><!--youtubeの埋め込みリンク-->
264
+
265
+ </div>
266
+
267
+ </div>
268
+
269
+ </div>-
270
+
271
+ </section>
272
+
273
+
274
+
275
+ <section class="contact">
276
+
277
+ <h2 id="contact">CONTACT</h2>
278
+
279
+ </section>
280
+
281
+
282
+
283
+ </header>
284
+
285
+
286
+
287
+ <footer>
288
+
289
+ <p>上に戻る</p>
290
+
291
+ <div class="sita">
292
+
293
+ </div>
294
+
295
+ </footer>
296
+
297
+ ```
298
+
299
+
300
+
301
+ CSS
302
+
303
+ ```
304
+
305
+ @charset "utf-8";
306
+
307
+
308
+
309
+ /* background-image: url("../img/wallpaper.jpg");*/
310
+
311
+ body{/*初期設定、余計なmargin,paddingを0に*/
312
+
313
+ font-size: 14px;
314
+
315
+ font-family: Verdana, sans-serif;
316
+
317
+ margin: 0;
318
+
319
+ padding: 0;
320
+
321
+ color: #333;
322
+
323
+ background: #f2f2f2;
324
+
325
+
326
+
327
+
328
+
329
+ /*初期設定*/
330
+
331
+ }
332
+
333
+ p{/*行間がゆったりする*/
334
+
335
+ line-height: 2;
336
+
337
+ }
338
+
339
+
340
+
341
+ .top {
342
+
343
+ width: 90%;
344
+
345
+ margin: 0 auto;
346
+
347
+ }
348
+
349
+
350
+
351
+ .menu {
352
+
353
+ display: block;/*要素の表示形式をしていするっぽい、ブロック要素を表示,,*/
354
+
355
+ /*46行目にheader-pc-menuを見えない設定をして、ここで820px以上いくとここで表示させる*/
356
+
357
+ list-style: none;
358
+
359
+ padding: 0;
360
+
361
+ margin: 0;
362
+
363
+ /*余計なマージンパディング取る、*/
364
+
365
+ float: right;/*mysiteも入っているheader-pc-menuの中に右にする設定*/
366
+
367
+
368
+
369
+ }
370
+
371
+
372
+
373
+ /*------------ボタンアニメーション---------------------*/
374
+
375
+ .btn::before {
376
+
377
+ content: '';
378
+
379
+ position: absolute;
380
+
381
+ bottom: 0%;
382
+
383
+ left: 0px;
384
+
385
+ width: 100%;
386
+
387
+ height: 1px;
388
+
389
+ background: #000000;
390
+
391
+ display: block;
392
+
393
+ -webkit-transform-origin: right top;
394
+
395
+ -ms-transform-origin: right top;
396
+
397
+ transform-origin: right top;
398
+
399
+ -webkit-transform: scale(0, 1);
400
+
401
+ -ms-transform: scale(0, 1);
402
+
403
+ transform: scale(0, 1);
404
+
405
+ -webkit-transition: transform 0.4s cubic-bezier(1, 0, 0, 1);
406
+
407
+ transition: transform 0.4s cubic-bezier(1, 0, 0, 1)
408
+
409
+ }
410
+
411
+
412
+
413
+ .btn:hover::before {
414
+
415
+ -webkit-transform-origin: left top;
416
+
417
+ -ms-transform-origin: left top;
418
+
419
+ transform-origin: left top;
420
+
421
+ -webkit-transform: scale(1, 1);
422
+
423
+ -ms-transform: scale(1, 1);
424
+
425
+ transform: scale(1, 1)
426
+
427
+ }
428
+
429
+
430
+
431
+ .btn{
432
+
433
+ padding: 15px 100px;
434
+
435
+ margin:10px 4px;
436
+
437
+ color: #000000;
438
+
439
+ font-family: sans-serif;
440
+
441
+ text-transform: uppercase;
442
+
443
+ text-align: center;
444
+
445
+ position: relative;
446
+
447
+ text-decoration: none;
448
+
449
+ display:inline-block;
450
+
451
+
452
+
453
+ display: inline-block;/*横にする設定*/
454
+
455
+ cursor: pointer;
456
+
457
+ margin: 15px;
458
+
459
+ padding: 0;
460
+
461
+ display: block;/*要素の表示形式をしていするっぽい、ブロック要素を表示,,*/
462
+
463
+ /*46行目にheader-pc-menuを見えない設定をして、ここで820px以上いくとここで表示させる*/
464
+
465
+ float: right;/*mysiteも入っているheader-pc-menuの中に右にする設定*/
466
+
467
+ }
468
+
469
+
470
+
471
+
472
+
473
+ /*---------------------------------*/
474
+
475
+
476
+
477
+ .top img {
478
+
479
+ display: inline-block;/*横にする設定*/
480
+
481
+ width: 50px;
482
+
483
+ height: 50px;
484
+
485
+ text-align: left;
486
+
487
+ cursor: pointer;
488
+
489
+ }
490
+
491
+
492
+
493
+ .container{/*ここで90%の意味はmysiteという上の文字や写真、写真のコメントなどをかこんでいて
494
+
495
+ 左右に一定の空きができる*/
496
+
497
+ width:80%;
498
+
499
+ margin: 0 auto;
500
+
501
+ }
502
+
503
+
504
+
505
+ .text{
506
+
507
+ width:80%;
508
+
509
+ margin: 0 auto;
510
+
511
+ max-width: 350px;}
512
+
513
+
514
+
515
+ section{
516
+
517
+ background: #fff;/*ここを消してbodyに画像指定すると背景が設定できる*/
518
+
519
+ padding: 60px 0;
520
+
521
+ }
522
+
523
+
524
+
525
+ section h2{/*文字を中央ぞろえ、下にマージン空き*/
526
+
527
+ text-align: center;
528
+
529
+ }
530
+
531
+
532
+
533
+ .icon{
534
+
535
+ /*背景画像*/
536
+
537
+ background-image: url("../img/wallpaper.jpg");
538
+
539
+ background-repeat: no-repeat;
540
+
541
+ background-attachment: fixed;/*背景を固定している*/
542
+
543
+ background-position: center;
544
+
545
+
546
+
547
+ padding-bottom: 600px;/*ここでpaddingを設定したからsectionのpaddingが無効に*/
548
+
549
+ }
550
+
551
+
552
+
553
+ .icon img{
554
+
555
+ display: block;
556
+
557
+ margin-left: auto;
558
+
559
+ margin-right: auto;
560
+
561
+ width: 150px;
562
+
563
+ height: 150px;
564
+
565
+ }
566
+
567
+
568
+
569
+
570
+
571
+ /*PROFILE*/
572
+
573
+ .profile .item{/*newsの囲っているやつを中央揃え*/
574
+
575
+ text-align: center;
576
+
577
+ }
578
+
579
+
580
+
581
+ .profile p{/*テキストまで中央になってしまったのでここで解除する*/
582
+
583
+ text-align: left;
584
+
585
+ }
586
+
587
+ /*features同様アイテム同士の空き*/
588
+
589
+ .profile .item{/*写真と文字を囲っているfeaturesの下の空き*/
590
+
591
+ margin-bottom: 10px;
592
+
593
+ }
594
+
595
+
596
+
597
+ .profile .item:last-child{/*これにだけ指定という意味*/
598
+
599
+ margin-bottom: 0;
600
+
601
+ }
602
+
603
+
604
+
605
+ /*GRAPHICS*/
606
+
607
+
608
+
609
+ .gra .container{
610
+
611
+ display: flex;
612
+
613
+ justify-content: space-between;/*均等に余白が空く設定*/
614
+
615
+ }
616
+
617
+
618
+
619
+ .gra .item{/*graに入っている画像と文字に対して30%*/
620
+
621
+ width: 30%;
622
+
623
+ text-align: center;
624
+
625
+ margin-bottom: 10px;
626
+
627
+ }
628
+
629
+
630
+
631
+ .gra .item img{/*画像が30%だとちゃんと見えないので画像だけ100%に*/
632
+
633
+ width: 100%;
634
+
635
+ }
636
+
637
+
638
+
639
+ .gra p{/*テキストまで中央になってしまったのでここで解除する*/
640
+
641
+ text-align: left;
642
+
643
+ }
644
+
645
+
646
+
647
+ .gra .item:last-child{/*これにだけ指定という意味*/
648
+
649
+ margin-bottom: 0;
650
+
651
+ }
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+ /*画像アニメーション*/
660
+
661
+
662
+
663
+ .photo-show {
664
+
665
+ height: 440px; /*表示したい大きさ*/
666
+
667
+ margin: 30px auto; /*縦余白30pxは任意*/
668
+
669
+ max-width: 100%;
670
+
671
+ /*position: relative;*/
672
+
673
+ width: 300px; /*表示したい大きさ、height と合わせる*/
674
+
675
+ }
676
+
677
+
678
+
679
+ .photo-show img {
680
+
681
+ animation: show 8s infinite;
682
+
683
+ -webkit-animation: show 8s infinite;
684
+
685
+ border-radius: 50%;
686
+
687
+ /*height: auto;*/
688
+
689
+ max-width: 100%;
690
+
691
+ opacity: 0;
692
+
693
+ position: absolute; /*画像を全て重ねる*/
694
+
695
+ }
696
+
697
+
698
+
699
+ /*アニメーション*/
700
+
701
+
702
+
703
+ @keyframes show {
704
+
705
+ 0% {opacity:0}
706
+
707
+ 20% {opacity:1}
708
+
709
+ 30% {opacity:1}
710
+
711
+ 40% {opacity:0}
712
+
713
+ }
714
+
715
+
716
+
717
+ @-webkit-keyframes show {
718
+
719
+ 0% {opacity:0}
720
+
721
+ 20% {opacity:1}
722
+
723
+ 30% {opacity:1}
724
+
725
+ 40% {opacity:0}
726
+
727
+ }
728
+
729
+
730
+
731
+ /*各画像のアニメーションの開始時間をずらす*/
732
+
733
+
734
+
735
+ .photo-show img:nth-of-type(1) {
736
+
737
+ animation-delay: 0s;
738
+
739
+ -webkit-animation-delay: 0s;
740
+
741
+ }
742
+
743
+
744
+
745
+ .photo-show img:nth-of-type(2) {
746
+
747
+ animation-delay: 2s;
748
+
749
+ -webkit-animation-delay: 2s;
750
+
751
+ }
752
+
753
+
754
+
755
+ .photo-show img:nth-of-type(3) {
756
+
757
+ animation-delay: 4s;
758
+
759
+ -webkit-animation-delay: 4s;
760
+
761
+ }
762
+
763
+
764
+
765
+ .photo-show img:nth-of-type(4) {
766
+
767
+ animation-delay: 6s;
768
+
769
+ -webkit-animation-delay: 6s;
770
+
771
+ }
772
+
773
+ /*
774
+
775
+ .photo-show img:nth-of-type(5) {
776
+
777
+ animation-delay: 8s;
778
+
779
+ -webkit-animation-delay: 8s
780
+
781
+ }
782
+
783
+
784
+
785
+ .photo-show img:nth-of-type(6) {
786
+
787
+ animation-delay: 10s;
788
+
789
+ -webkit-animation-delay: 10s;
790
+
791
+ }
792
+
793
+
794
+
795
+ .photo-show img:nth-of-type(7) {
796
+
797
+ animation-delay: 12s;
798
+
799
+ -webkit-animation-delay: 12s;
800
+
801
+ }
802
+
803
+ .photo-show img:nth-of-type(8) {
804
+
805
+ animation-delay: 14s;
806
+
807
+ -webkit-animation-delay: 14s;
808
+
809
+ }*/
810
+
811
+
812
+
813
+ /*マウスが画像に重なった際、動きを止めて四角くする*/
814
+
815
+
816
+
817
+ .photo-show img {
818
+
819
+ transition: 0.2s;
820
+
821
+ -webkit-transition: 0.2s;
822
+
823
+ }
824
+
825
+
826
+
827
+ .photo-show:hover img {
828
+
829
+ animation-play-state: paused;
830
+
831
+ -webkit-animation-play-state: paused;
832
+
833
+ border-radius: 0;
834
+
835
+ }
836
+
837
+
838
+
839
+
840
+
841
+ /*MUSIC*/
842
+
843
+
844
+
845
+ .music-container{/*ここで90%の意味はmysiteという上の文字や写真、写真のコメントなどをかこんでいて
846
+
847
+ 左右に一定の空きができる*/
848
+
849
+ width: 80%;
850
+
851
+ margin: 0 auto;
852
+
853
+ }
854
+
855
+
856
+
857
+ .music iframe{
858
+
859
+ position: absolute;
860
+
861
+ width: 100%;
862
+
863
+ height: 100%;
864
+
865
+ top: 0;
866
+
867
+ left: 0;
868
+
869
+ }
870
+
871
+
872
+
873
+
874
+
875
+ .music-wrapper {/*padding-topかbottomで%を指定するとcssで、widthに対する比率となる、56.25はyoutubeの16:9の比率を指定*/
876
+
877
+ padding-bottom: 56.25%;
878
+
879
+ height: 0;
880
+
881
+ position: relative;
882
+
883
+ }
884
+
885
+
886
+
887
+
888
+
889
+
890
+
891
+
892
+
893
+ /*画面が570px以上になったとき*/
894
+
895
+ @media (min-width: 570px){
896
+
897
+ .container{
898
+
899
+ width: 570px;
900
+
901
+ }
902
+
903
+
904
+
905
+ .music-container{
906
+
907
+ width:570px;
908
+
909
+ }
910
+
911
+ }
912
+
913
+
914
+
915
+ /*画面が570px以上になったとき*/
916
+
917
+ @media (min-width: 820px){
918
+
919
+ .container{
920
+
921
+ width: 820px;
922
+
923
+ }
924
+
925
+
926
+
927
+ .music-container{
928
+
929
+ width:820px;
930
+
931
+ }
932
+
933
+ }```