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

回答編集履歴

2

コード修正+サンプルリンク追記

2019/12/16 08:23

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -1,3 +1,4 @@
1
+ ### 案1
1
2
  `#left` に `position: absolute;` が設定してあるので、あとは `top:` で適切な位置を指定すればいいでしょう。
2
3
 
3
4
  ```css
@@ -9,20 +10,49 @@
9
10
  margin: auto;
10
11
  }
11
12
  ```
12
-
13
+ ### 案2
13
14
  あるいは、
14
15
  imgタグではなく、CSSの`background-image`に画像を設定してはどうですか。
15
16
  HTMLの `id=gazou` や `id=tickets_sheet` のブロックは不要になります。
17
+ ```html
18
+ <div id="gazou">
19
+ <div id="left">
20
+ <ul>
21
+ <li><span class="price">01. </span><span class="price_title">入場券</span><span class="price_title2">
22
+ (お一人につき一枚必要) </span>‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥ <span class="price">&yen;3,000</span>
23
+ </li>
24
+ <li><span class="price">02. </span><span class="price_title">テント券</span><span class="price_title2">
25
+ (ひと組につき一枚必要) </span>‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥ <span class="price">&yen;3,000</span>
26
+ </li>
27
+ <li><span class="price">03. </span><span class="price_title">ロッジ券</span><span class="price_title2">
28
+ (ひと組につき一枚必要) </span>‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥ <span class="price">&yen;8,000</span>
29
+ </li>
30
+ <li><span class="price">04. </span><span class="price_title">グランピングテント券</span><span
31
+ class="price_title2"> (ひと組につき一枚必要) </span>‥‥‥‥‥‥‥‥‥ <span class="price">&yen;12,000</span>
32
+ </li>
33
+ <p id="tickets_higaeri">*日帰り利用(16日限定)を希望される場合も入場券をお求めください。</p>
34
+ </ul>
35
+ </div>
36
+ </div>
37
+ ```
16
38
 
17
39
  ```css
40
+ #gazou{
41
+ /* position: relative; */
42
+ /* 以下追加 */
43
+ background-color: #b8ebd3;
44
+ padding: 20px;
45
+ }
18
46
  #left{
19
- position: absolute;
47
+ /* position: absolute;
20
48
  left: 0;
21
- right: 0;
49
+ right: 0; */
22
- margin: auto;
50
+ margin: auto;
23
51
  /* 以下追加 */
24
52
  width: 936px;
25
53
  height: 582px;
26
- background-image: url(hukidasi.png);
54
+ background-image: url(https://placehold.jp/150/9599de/868bd1/936x582.png?text=gazou);
27
55
  }
28
- ```
56
+ ```
57
+
58
+ [動作確認用サンプル](https://codepen.io/hatena19/pen/ZEYBEwx)

1

コード追加

2019/12/16 08:23

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -1,6 +1,20 @@
1
- imgタグではなく、CSSのbackground-image画像を設定るのではだめです
1
+ `#left` `position: absolute;` が設定してあるので、あと `top:` 適切な位置を指定ればいいでしょう
2
2
 
3
3
  ```css
4
+ #left {
5
+ position: absolute;
6
+ top: 25px; /* 追加 */
7
+ left: 0;
8
+ right: 0;
9
+ margin: auto;
10
+ }
11
+ ```
12
+
13
+ あるいは、
14
+ imgタグではなく、CSSの`background-image`に画像を設定してはどうですか。
15
+ HTMLの `id=gazou` や `id=tickets_sheet` のブロックは不要になります。
16
+
17
+ ```css
4
18
  #left{
5
19
  position: absolute;
6
20
  left: 0;