二维码

常用组件

常用组件

对话框

显示屏幕居中的对话框。

1
2
3
4
<div id="dialog">
<p>I am the dialog's content</p>
<button type="button">close dialog</button>
</div>
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
#dialog {
position: fixed;
top: 50%;
left: 50%;
width: 400px;
height: 200px;
transform: translate3d(-50%,-50%,0);
background: white;
border: 100% solid rgba(0, 0, 0, 2.5);
}

#dialog:before {
content: "";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.25);
z-index: 999;

/* fade in */
transition: opacity 0.2s ease-in-out;
}

#dialog[hidden] {
/*
[hidden] usually sets display:none, which we
need to revert in order to allow animations
*/
display: block;
/*
actually hide the element,
making its contents unaccessible
*/
visibility: hidden;
/*
make sure the element is out of viewport
*/
transform: translate3d(0px, -1px, 0px) scale(0);
/*
delay transform until animations are done
*/
transition:
visibility 0s linear 0.2s,
transform 0s linear 0.2s;
}

参考链接


本教程来自“网道项目”(wangdoc.com),采用知识共享 署名-相同方式共享 3.0协议