回答編集履歴

4

誤解

2019/02/25 10:02

投稿

yu-smc
yu-smc

スコア610

test CHANGED
@@ -1,61 +1 @@
1
- 取れません。
2
-
3
-
4
-
5
- その場合、さらに親でposition: relativeな要素があればその要素に、なければhtml要素基準になります。
6
-
7
-
8
-
9
- 同じ効果を実現するなら、
10
-
11
- ```html
12
-
13
- <div class="parent"></div>
14
-
15
- <div class="dummy"></div>
16
-
17
- <div class="child"></div>
18
-
19
- ```
20
-
21
-
22
-
23
- ```css
24
-
25
- .parent {
26
-
27
- position: absolute;
28
-
29
- /* その他略 */
30
-
31
- }
32
-
33
-
34
-
35
- .dummy {
36
-
37
- position: relative;
38
-
39
- width: 100%;
40
-
41
- height: 100%;
42
-
43
- }
44
-
45
-
46
-
47
- .child {
48
-
49
- position: absolute;
50
-
51
- /* その他略 */
52
-
53
- }
54
-
55
- ```
56
-
57
-
58
-
59
- でできます。
60
-
61
- この場合親要素のheightが明記されている必要があります。
1
+ すみません誤解した回答を載せていましたので一旦文章を削除します。

3

コードの追加

2019/02/25 10:02

投稿

yu-smc
yu-smc

スコア610

test CHANGED
@@ -8,12 +8,54 @@
8
8
 
9
9
  同じ効果を実現するなら、
10
10
 
11
- 親要素・・・position: absolute
11
+ ```html
12
12
 
13
- ダミー要素(親要素と同じサイズ)・・・position: relative
13
+ <div class="parent"></div>
14
14
 
15
+ <div class="dummy"></div>
16
+
17
+ <div class="child"></div>
18
+
19
+ ```
20
+
21
+
22
+
23
+ ```css
24
+
25
+ .parent {
26
+
15
- 子要素・・・position:absolute
27
+ position: absolute;
28
+
29
+ /* その他略 */
30
+
31
+ }
32
+
33
+
34
+
35
+ .dummy {
36
+
37
+ position: relative;
38
+
39
+ width: 100%;
40
+
41
+ height: 100%;
42
+
43
+ }
44
+
45
+
46
+
47
+ .child {
48
+
49
+ position: absolute;
50
+
51
+ /* その他略 */
52
+
53
+ }
54
+
55
+ ```
16
56
 
17
57
 
18
58
 
19
59
  でできます。
60
+
61
+ この場合、親要素のheightが明記されている必要があります。

2

補足

2019/02/25 09:13

投稿

yu-smc
yu-smc

スコア610

test CHANGED
@@ -8,11 +8,11 @@
8
8
 
9
9
  同じ効果を実現するなら、
10
10
 
11
- 親要素・・・position: absolute
11
+ 親要素・・・position: absolute
12
12
 
13
- ダミー要素・・・position: relative
13
+ ダミー要素(親要素と同じサイズ)・・・position: relative
14
14
 
15
- 子要素・・・position:absolute
15
+ 子要素・・・position:absolute
16
16
 
17
17
 
18
18
 

1

gozi

2019/02/25 09:09

投稿

yu-smc
yu-smc

スコア610

test CHANGED
File without changes