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

質問編集履歴

1

追加情報

2020/06/01 02:26

投稿

augsup
augsup

スコア7

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,146 @@
1
1
  現在htmlとscssを用いて[Airbnb](https://www.airbnb.jp/host/homes)の模写コーディングをしています。
2
2
  そこでhederの固定をすると1枚目の写真のようにmainの画像と被ってしまいます。
3
3
  これを2枚目の写真のようにmainの画像と被らずに固定するにはどうすればいいのでしょうか?
4
+ 私が書いたコードも載せておきます。
4
5
  ![イメージ説明](c324e87f4bab4b5c37bee742b7e1409a.png)
5
- ![イメージ説明](550a1865802537795bb437c6841f510d.png)
6
+ ![イメージ説明](550a1865802537795bb437c6841f510d.png)
7
+ ```HTML
8
+ <!DOCTYPE html>
9
+ <html lang="ja">
10
+ <head>
11
+ <meta charset="UTF-8">
12
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
13
+ <title>Airbnbでお家、アパート、お部屋をシェアしよう</title>
14
+ <link rel="stylesheet" href="css/stylesheet.css">
15
+ </head>
16
+ <body>
17
+ <header>
18
+ <div class="header-ctn-left">
19
+ <img src="img/head.svg" alt="">
20
+ <a href="">概要</a>
21
+ <a href="">準備</a>
22
+ <a href="">安全</a>
23
+ <a href="">マネープラン</a>
24
+ </div>
25
+ <button type="button">はじめる</button>
26
+ </header>
27
+ <main>
28
+ <section class="eyecatch">
29
+ <div class="eyecatch-ctn">
30
+ <p>Airbnbホストになって、暮らしをレベルアップ</p>
31
+ <p>宿泊施設の内容を記入</p>
32
+ <input type=" text " placeholder="ロケーション">
33
+ <div>
34
+ <select name="部屋" id="">
35
+ <option value="">まるまる貸し切り</option>
36
+ <option value="">個室</option>
37
+ <option value="">シェアルーム</option>
38
+ </select>
39
+ <select name="人数" id="">
40
+ <option value="">ゲスト1人</option>
41
+ <option value="">ゲスト2人</option>
42
+ <option value="">ゲスト3人</option>
43
+ <option selected=slected value="">ゲスト4人</option>
44
+ <option value="">ゲスト5人</option>
45
+ <option value="">ゲスト6人</option>
46
+ <option value="">ゲスト7人</option>
47
+ <option value="">ゲスト8人</option>
48
+ <option value="">ゲスト9人</option>
49
+ <option value="">ゲスト10人</option>
50
+ <option value="">ゲスト11人</option>
51
+ <option value="">ゲスト12人</option>
52
+ </select>
53
+ </div>
54
+ <button type="button">はじめる</button>
55
+ </div>
56
+ </section>
57
+ </main>
58
+ </body>
59
+ </html>
60
+ ```
61
+ ```css
62
+ body{
63
+ margin: 0;
64
+ }
65
+ header{
66
+ width: 100%;
67
+ height: 81px;
68
+ background-color: white;
69
+ display: flex;
70
+ z-index: 1;
71
+ position: fixed;
72
+ justify-content: space-between;
73
+ align-items: center;
74
+ .header-ctn-left{
75
+ margin-left: 20px;
76
+ >*{
77
+ color: #484848;
78
+ margin-right: 20px;
79
+ text-decoration: none;
80
+ }
81
+ a{
82
+ &:hover{
83
+ border-bottom: solid 1px #484848;;
84
+ }
85
+ }
86
+ img{
87
+ width: 37px;
88
+ vertical-align: middle;
89
+ }
90
+ }
91
+ button{
92
+ width: 91px;
93
+ font-weight: bold;
94
+ height: 37px;
95
+ margin-right: 43px;
96
+ background-color: #DB3742;
97
+ border: none;
98
+ border-radius: 5px;
99
+ color: white;
100
+ }
101
+ }
102
+ main{
103
+ .eyecatch{
104
+ background-image: url(../img/eyecatch.jpg);
105
+ height: 600px;
106
+ background-size: cover;
107
+ background-repeat: no-repeat;
108
+ background-position: center top;
109
+ position: relative;
110
+ .eyecatch-ctn{
111
+ position: absolute;
112
+ right:20px;
113
+ top: 50%;
114
+ transform: translate(0,-50%);
115
+ background-color: white;
116
+ height: 423px;
117
+ width: 460px;
118
+ p:nth-of-type(1){
119
+ font-size: 40px;
120
+ font-weight: 800;
121
+ margin: 0 32px;
122
+ line-height: 40px;
123
+ }
124
+ p{
125
+ font-size: 16px;
126
+ font-weight: bold;
127
+ }
128
+ input{
129
+ height: 38px;
130
+ width: 100%;
131
+ box-sizing: border-box;
132
+ }
133
+ select:nth-of-type(1){
134
+ box-sizing: border-box;
135
+ height: 38px;
136
+ width: 50%;
137
+ }
138
+ select:nth-of-type(2){
139
+ box-sizing: border-box;
140
+ height: 38px;
141
+ width: 40%;
142
+ }
143
+ }
144
+ }
145
+ }
146
+ ```