回答編集履歴

1

こぴぺ

2019/05/31 05:11

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -47,3 +47,149 @@
47
47
 
48
48
 
49
49
  ````
50
+
51
+
52
+
53
+ # コピペ用
54
+
55
+ コピペで動かないというので以下をコピペしてください
56
+
57
+ (HTMLやCSSは元ソースからいじってません)
58
+
59
+ ```javascript
60
+
61
+ <style>
62
+
63
+ div#modal {
64
+
65
+ display: none;
66
+
67
+ z-index: 1;
68
+
69
+ position: fixed;
70
+
71
+ top: 0;
72
+
73
+ left: 0;
74
+
75
+ right: 0;
76
+
77
+ bottom: 0;
78
+
79
+ height: 100%;
80
+
81
+ width: 100%;
82
+
83
+ overflow: auto;
84
+
85
+ background-color: rgba(0,0,0,0.5);
86
+
87
+ }
88
+
89
+
90
+
91
+ div#modal div.modal-content {
92
+
93
+ width: 600px;
94
+
95
+ height: 500px;
96
+
97
+ position: absolute;
98
+
99
+ top: 100px;
100
+
101
+ left: calc(50% - 300px);
102
+
103
+ background-color: white;
104
+
105
+ justify-content: center;
106
+
107
+ align-items: center;
108
+
109
+ }
110
+
111
+
112
+
113
+ div.modal-content a {
114
+
115
+ position: absolute;
116
+
117
+ right: 10px;
118
+
119
+ top: 0px;
120
+
121
+ font-size: 40px;
122
+
123
+ font-weight: bold;
124
+
125
+ }
126
+
127
+ </style>
128
+
129
+ <script>
130
+
131
+ window.addEventListener('DOMContentLoaded', function(e){
132
+
133
+ var btn = document.querySelector('#modal_open');
134
+
135
+ var btn_close = document.querySelector('#modal_close');
136
+
137
+ var modal = document.querySelector('#modal');
138
+
139
+ btn.querySelector('a').addEventListener('click',function(e) {
140
+
141
+ e.preventDefault();
142
+
143
+ modal.style.display = 'block';
144
+
145
+ });
146
+
147
+ btn_close.addEventListener('click',function() {
148
+
149
+ modal.style.display = 'none';
150
+
151
+ });
152
+
153
+ modal.addEventListener('click',function(e) {
154
+
155
+ e.preventDefault();
156
+
157
+ });
158
+
159
+ window.addEventListener('click',function(e) {
160
+
161
+ if(e.target== modal) {
162
+
163
+ modal.style.display = 'none';
164
+
165
+ }
166
+
167
+ });
168
+
169
+ });
170
+
171
+ </script>
172
+
173
+ <div id="modal">
174
+
175
+ <div class="modal-content f_wrap">
176
+
177
+ <a href="#" id="modal_close">×</a>
178
+
179
+ <img src="images/img.jpg" width="500px" height="400px" alt="スケジュール">
180
+
181
+ </div>
182
+
183
+ </div>
184
+
185
+ <p id="modal_open">
186
+
187
+ <a href="">
188
+
189
+ <img src="images/img.jpg" width="200px" height="200px" alt="スケジュール">
190
+
191
+ </a>
192
+
193
+ </p>
194
+
195
+ ```