回答編集履歴
1
こぴぺ
answer
CHANGED
@@ -22,4 +22,77 @@
|
|
22
22
|
});
|
23
23
|
});
|
24
24
|
|
25
|
-
````
|
25
|
+
````
|
26
|
+
|
27
|
+
# コピペ用
|
28
|
+
コピペで動かないというので以下をコピペしてください
|
29
|
+
(HTMLやCSSは元ソースからいじってません)
|
30
|
+
```javascript
|
31
|
+
<style>
|
32
|
+
div#modal {
|
33
|
+
display: none;
|
34
|
+
z-index: 1;
|
35
|
+
position: fixed;
|
36
|
+
top: 0;
|
37
|
+
left: 0;
|
38
|
+
right: 0;
|
39
|
+
bottom: 0;
|
40
|
+
height: 100%;
|
41
|
+
width: 100%;
|
42
|
+
overflow: auto;
|
43
|
+
background-color: rgba(0,0,0,0.5);
|
44
|
+
}
|
45
|
+
|
46
|
+
div#modal div.modal-content {
|
47
|
+
width: 600px;
|
48
|
+
height: 500px;
|
49
|
+
position: absolute;
|
50
|
+
top: 100px;
|
51
|
+
left: calc(50% - 300px);
|
52
|
+
background-color: white;
|
53
|
+
justify-content: center;
|
54
|
+
align-items: center;
|
55
|
+
}
|
56
|
+
|
57
|
+
div.modal-content a {
|
58
|
+
position: absolute;
|
59
|
+
right: 10px;
|
60
|
+
top: 0px;
|
61
|
+
font-size: 40px;
|
62
|
+
font-weight: bold;
|
63
|
+
}
|
64
|
+
</style>
|
65
|
+
<script>
|
66
|
+
window.addEventListener('DOMContentLoaded', function(e){
|
67
|
+
var btn = document.querySelector('#modal_open');
|
68
|
+
var btn_close = document.querySelector('#modal_close');
|
69
|
+
var modal = document.querySelector('#modal');
|
70
|
+
btn.querySelector('a').addEventListener('click',function(e) {
|
71
|
+
e.preventDefault();
|
72
|
+
modal.style.display = 'block';
|
73
|
+
});
|
74
|
+
btn_close.addEventListener('click',function() {
|
75
|
+
modal.style.display = 'none';
|
76
|
+
});
|
77
|
+
modal.addEventListener('click',function(e) {
|
78
|
+
e.preventDefault();
|
79
|
+
});
|
80
|
+
window.addEventListener('click',function(e) {
|
81
|
+
if(e.target== modal) {
|
82
|
+
modal.style.display = 'none';
|
83
|
+
}
|
84
|
+
});
|
85
|
+
});
|
86
|
+
</script>
|
87
|
+
<div id="modal">
|
88
|
+
<div class="modal-content f_wrap">
|
89
|
+
<a href="#" id="modal_close">×</a>
|
90
|
+
<img src="images/img.jpg" width="500px" height="400px" alt="スケジュール">
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
<p id="modal_open">
|
94
|
+
<a href="">
|
95
|
+
<img src="images/img.jpg" width="200px" height="200px" alt="スケジュール">
|
96
|
+
</a>
|
97
|
+
</p>
|
98
|
+
```
|