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

質問編集履歴

1

html編集、sass追加

2019/01/11 02:06

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -9,26 +9,84 @@
9
9
  を適用させたい
10
10
 
11
11
  ```ここに言語を入力
12
- <header>
13
- <!-- ヘッダー -->
14
- </header>
12
+ <header class="l-header">header</header>
15
13
 
16
- <div class="content">
14
+ <div class="l-container">
15
+ <aside class="l-sidebar">
16
+ <div class="l-sidebar__inner">
17
- <main>
17
+ <ul>
18
+ <li class="l-sidebar__item">menu</li>
19
+ <li class="l-sidebar__item">menu</li>
20
+ <li class="l-sidebar__item">menu</li>
21
+ <li class="l-sidebar__item">menu</li>
22
+ <li class="l-sidebar__item">menu</li>
23
+ <li class="l-sidebar__item">menu</li>
24
+ <li class="l-sidebar__item">menu</li>
25
+ <li class="l-sidebar__item">menu</li>
26
+ <li class="l-sidebar__item">menu</li>
27
+ <li class="l-sidebar__item">menu</li>
28
+ <li class="l-sidebar__item">menu</li>
29
+ <li class="l-sidebar__item">menu</li>
30
+ </ul>
31
+ </div>
18
- <!-- メインコンテンツ -->
32
+ </aside>
33
+ <main class="l-main">
34
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
35
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
36
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
37
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
38
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
39
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
40
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
41
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
42
+ <p>text</p><p>text</p><p>text</p><p>text</p><p>text</p>
19
- </main>
43
+ </main>
20
- <div class="sidebar">
21
- <!-- サイドバー -->
22
44
  </div>
23
- </div>
24
45
 
25
- <footer>
26
- <!-- フッター -->
27
- </footer>
46
+ <footer class="l-footer">footer</footer>
28
47
  ```
29
48
 
30
- ### つまずいている箇所
49
+ ```
31
50
 
51
+ .l-header,
52
+ .l-footer
53
+ color: #fff
54
+ text-align: center
55
+ height: 50px
56
+ line-height: 50px
57
+ background-color: #333
58
+
59
+ .l-container
60
+ display: flex
61
+
62
+ .l-sidebar
63
+ width: 250px
64
+ min-width: 250px
65
+ height: 100%
66
+ &__inner
67
+ width: 250px
68
+ min-width: 250px
69
+ height: 100%
70
+ position: fixed
71
+ top: 50px
72
+ left: 0
73
+ overflow-y: scroll
74
+ background-color: #f00
75
+ &__item
76
+ padding: 20px
77
+
78
+ .l-main
79
+ width: calc(100% - 250px)
80
+ background-color: #eee
81
+ ```
82
+
83
+ ### 上記のhtmlとsassでの問題点
84
+
85
+ - スクロールしたら、サイドバーの上に隙間が空いてしまう(ヘッダーの高さ分、topで下にずらしているから)
86
+ - 下までスクロールしたら、fixedで固定している箇所(左側)がフッターの上に来てしまう
87
+
88
+ ### 試したこと
89
+
32
90
  - position: stickyとoverflow-y: scrollの共存が不可能(親にposition、子にoverflowでも無理)だった
33
91
  - stickyではなくfixedで固定させようとしたら、下までスクロールした時にフッターの上にかぶってしまい、フッターが一部隠れてしまう
34
92
  - サイドバーに背景色がついているから、高さを100%にしなければフッターとサイドバーとの空間に隙間が空いているように見えてしまう(vh100%など試してみたが駄目だった)