-
Notifications
You must be signed in to change notification settings - Fork 0
/
prueba.html
58 lines (56 loc) · 1.45 KB
/
prueba.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<body>
<custom-dialog>
<button id="dialog-btn">Open</button>
<dialog id="dialogo">
<button id="close-btn" class="close-btn">🗙</button>
<h1>Dialog</h1>
<p>This is a dialog.</p>
</dialog>
</custom-dialog>
<style>
.close-btn {
background-color: #f44336;
color: white;
border: none;
cursor: pointer;
padding: 10px 20px;
position: absolute;
right: 0;
top: 0;
}
dialog {
background-color: #ffffff;
border-radius: 4px;
box-shadow: 0 0 10px #00000061;
width: 400px;
padding: 20px;
position: relative;
text-align: center;
}
dialog::backdrop{
background-color: rgba(0, 0, 0, 0.5);
}
</style>
<script>
class CustomDialog extends HTMLElement {
constructor() {
super();
}
connectedCallback() {
let btnabrir = this.querySelector('#dialog-btn');
let btncerrar = this.querySelector('#close-btn');
let dialogo = this.querySelector('#dialogo');
btnabrir.addEventListener('click', function(){
dialogo.showModal();
})
btncerrar.addEventListener('click',function(){
dialogo.close();
})
}
}
customElements.define('custom-dialog', CustomDialog);
</script>
</body>
</html>