質問編集履歴

2

変更しました

2024/01/25 09:38

投稿

zindex_1
zindex_1

スコア9

test CHANGED
File without changes
test CHANGED
@@ -59,7 +59,7 @@
59
59
  width: 100%;
60
60
  height: 100%;
61
61
  background: #000000;
62
- opacity: 0.5;
62
+ opacity: 0.8;
63
63
  top: 0;
64
64
  left: 0;
65
65
  z-index: 1;
@@ -90,7 +90,7 @@
90
90
  }
91
91
 
92
92
  .message {
93
- color: rgb(255, 255, 255) !important;
93
+ color: rgba(255, 255, 255) !important;
94
94
  opacity:1 !important;
95
95
  font-weight: bold;
96
96
  font-size: 15px;
@@ -114,7 +114,7 @@
114
114
  要素3 {
115
115
  position: relative;
116
116
  z-index: 999;
117
- background-color: rgb(0,0,0,0) !important ;
117
+ background-color: rgba(0,0,0,0) !important ;
118
118
  opacity: 1 !important ;
119
119
  }
120
120
 

1

修正しました

2024/01/25 09:20

投稿

zindex_1
zindex_1

スコア9

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,6 @@
1
+ ```ここに言語を入力
2
+ コード
1
- ### 実現したいこと
3
+ ```### 実現したいこと
2
4
  親要素の背景色を子要素に引き継がないように設定したい。
3
5
 
4
6
  ### 発生している問題・分からないこと
@@ -15,8 +17,90 @@
15
17
  ### 該当のソースコード
16
18
 
17
19
  ```
18
- 特になし
20
+ HTML
19
21
  ```
22
+
23
+ <!DOCTYPE HTML>
24
+ <html>
25
+ <head>
26
+ <title>Sample</title>
27
+ <meta charset="UTF-8" />
28
+ <link href="css/sample.css" rel="stylesheet" />
29
+ </head>
30
+ <body style="background: red;">
31
+ <script>
32
+ window.onload = function(){
33
+
34
+ const BG1 = document.createElement('div');
35
+ BG1.classList.add('BG');
36
+ BG1.style.display = "block";
37
+ document.body.appendChild(BG1);
38
+
39
+
40
+ const Icon = document.createElement('div');
41
+ Icon.classList.add('setting');
42
+ Icon.innerHTML += '<div class="icon" >アイコン</div>';
43
+
44
+ Icon.innerHTML += '<div class="message">文字の表示</div>';
45
+
46
+ BG1.appendChild(Icon);
47
+ }
48
+ </script>
49
+ </body>
50
+ </html>
51
+
52
+ ```css
53
+
54
+ @charset "UTF-8";
55
+
56
+ .BG {
57
+ display: none;
58
+ position: fixed;
59
+ width: 100%;
60
+ height: 100%;
61
+ background: #000000;
62
+ opacity: 0.5;
63
+ top: 0;
64
+ left: 0;
65
+ z-index: 1;
66
+ }
67
+
68
+ .setting {
69
+ display: block;
70
+ position: absolute;
71
+ text-align:center;
72
+ background-color: rgba(0, 0, 0, 0);
73
+ padding: 20px 50px 40px 50px;
74
+ margin: auto;
75
+ width: 50%;
76
+ height: auto;
77
+ top: 35%;
78
+ left: 0;
79
+ right: 0;
80
+ z-index: 2;
81
+ }
82
+
83
+ .icon {
84
+ color: rgb(255, 255, 255) !important;
85
+ width: 50px;
86
+ height:50px;
87
+ top: 35%;
88
+ left: 0;
89
+ right: 0;
90
+ }
91
+
92
+ .message {
93
+ color: rgb(255, 255, 255) !important;
94
+ opacity:1 !important;
95
+ font-weight: bold;
96
+ font-size: 15px;
97
+ margin-top:30px;
98
+ position:relative;
99
+ z-index:999;
100
+ }
101
+
102
+ ```
103
+
20
104
 
21
105
  ### 試したこと・調べたこと
22
106
  - [ ] teratailやGoogle等で検索した