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

回答編集履歴

2

コードの微調整

2018/08/01 14:57

投稿

takopo
takopo

スコア484

answer CHANGED
@@ -31,6 +31,10 @@
31
31
  3つ目は、float を使った方法で、ロゴに float: left 、リストに float: right を指定します。
32
32
  この場合ヘッダーにはclearfixを指定する必要があります。
33
33
  ```ここに言語を入力
34
+ .header {
35
+ background-color: #6495ED;
36
+ }
37
+
34
38
  /* clearfix */
35
39
  .header::after {
36
40
  display: block;

1

floatを使った方法を追加しました

2018/08/01 14:57

投稿

takopo
takopo

スコア484

answer CHANGED
@@ -1,21 +1,21 @@
1
- 2つ方法があるのですが、1つはフレックスボックスを使った方法で、以下のように .header に display: flex を指定します。justify-content: space-between という部分で、ロゴとリストをそれぞれ両端揃えにしています。
1
+ 3つ方法があるのですが、1つはフレックスボックスを使った方法で、以下のように .header に display: flex を指定します。justify-content: space-between という部分で、ロゴとリストをそれぞれ両端揃えにしています。
2
2
  ```ここに言語を入力
3
- .header{
3
+ .header {
4
4
  display: flex;
5
5
  justify-content: space-between; /* 中身の要素を両端揃え */
6
6
  background-color: #6495ED;
7
7
  }
8
8
  ```
9
9
 
10
- もう1つは .header に position: relative を指定して、中身の要素に position: absolute を指定する方法です。この場合ヘッダーに高さを指定する必要があります。
10
+ 2 .header に position: relative を指定して、中身の要素に position: absolute を指定する方法です。この場合ヘッダーに高さを指定する必要があります。
11
11
  ```css
12
- .header{
12
+ .header {
13
13
  position: relative;
14
14
  height: 100px; /* ヘッダーの高さを指定します */
15
15
  background-color: #6495ED;
16
16
  }
17
17
 
18
- .header-logo{
18
+ .header-logo {
19
19
  position: absolute;
20
20
  left: 0; /* 左からの位置 */
21
21
  top: 20px; /* 上からの位置 */
@@ -26,4 +26,23 @@
26
26
  right: 0; /* 右からの位置 */
27
27
  top: 20px; /* 上からの位置 */
28
28
  }
29
+ ```
30
+
31
+ 3つ目は、float を使った方法で、ロゴに float: left 、リストに float: right を指定します。
32
+ この場合ヘッダーにはclearfixを指定する必要があります。
33
+ ```ここに言語を入力
34
+ /* clearfix */
35
+ .header::after {
36
+ display: block;
37
+ clear: both;
38
+ content: '';
39
+ }
40
+
41
+ .header-logo {
42
+ float: left;
43
+ }
44
+
45
+ .header-list {
46
+ float: right;
47
+ }
29
48
  ```