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
|
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>hangge.com</
title
>
<
style
>
html, body, div, span, h1, h2, h3 {
margin: 0;
padding: 0;
border: 0;
}
.demo {
width: 100vw;
font-size: 5vw;
margin: 0 auto;
color: #FFF;
}
.demo2 {
width: 80vw;
font-size: 5vw;
margin: 0 auto;
}
.demo3 {
width: 50vw;
height: 50vh;
font-size: 1vw;
margin: 0 auto;
color: #FFF;
}
</
style
>
</
head
>
<
body
>
<
div
class
=
"demo"
>
<
h1
>寬度100%, 字體5%</
h1
>
</
div
>
<
div
class
=
"demo2"
>
<
h2
>寬度80%, 字體5%</
h2
>
</
div
>
<
div
class
=
"demo3"
>
<
h3
>寬度50%, 高度50%, 字體1%</
h3
>
</
div
>
</
body
>
</
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
|
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>hangge.com</
title
>
<
style
>
html, body, div, span, button {
margin: 0;
padding: 0;
border: 0;
}
button {
width: 120px;
height: 30px;
color: #FFFFFF;
font-family: "微軟雅黑";
font-size: 14px;
background: #28B995;
}
#mask {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
background: #000000;
opacity: 0.5;
display: none;
}
</
style
>
</
head
>
<
body
>
<
button
onclick
=
"document.getElementById('mask').style.display='inline'"
>點擊顯示遮罩</
button
>
<
div
id
=
"mask"
onclick
=
"document.getElementById('mask').style.display='none'"
/></
div
>
</
body
>
</
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>hangge.com</
title
>
<
script
type
=
"text/javascript"
src
=
"js/jquery.js"
></
script
>
<
style
>
html, body, div, span, button {
margin: 0;
padding: 0;
border: 0;
}
button {
width: 120px;
height: 30px;
color: #FFFFFF;
font-family: "微軟雅黑";
font-size: 14px;
background: #28B995;
}
.dialog-container {
display: none;
width: 100vw;
height: 100vh;
text-align: center;
position: fixed;
top: 0;
left: 0;
z-index: 10;
}
.dialog-container:after {
display: inline-block;
content: '';
width: 0;
height: 100%;
vertical-align: middle;
}
.dialog-box {
display: inline-block;
border: 1px solid #ccc;
text-align: left;
vertical-align: middle;
position: relative;
}
.dialog-title {
line-height: 28px;
padding-left: 5px;
padding-right: 5px;
border-bottom: 1px solid #ccc;
font-size: 12px;
text-align: left;
}
.dialog-close {
position: absolute;
top: 5px;
right: 5px;
font-size: 12px;
}
.dialog-body {
}
</
style
>
</
head
>
<
body
>
<
button
onclick
=
"$('#dialogContainer').show();"
>點擊顯示彈出框</
button
>
<
div
id
=
"dialogContainer"
class
=
"dialog-container"
>
<
div
class
=
"dialog-box"
>
<
div
class
=
"dialog-title"
>居中彈出框</
div
>
<
a
onclick
=
"$('#dialogContainer').hide();"
class
=
"dialog-close"
>關閉</
a
>
<
div
class
=
"dialog-body"
>
<
img
src
=
"logo.png"
class
=
"demo-image"
/>
</
div
>
</
div
>
</
div
>
</
body
>
</
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>hangge.com</
title
>
<
script
type
=
"text/javascript"
src
=
"js/jquery.js"
></
script
>
<
style
>
html, body, div, span, button {
margin: 0;
padding: 0;
border: 0;
}
button {
width: 120px;
height: 30px;
color: #FFFFFF;
font-family: "微軟雅黑";
font-size: 14px;
background: #28B995;
}
.dialog-container {
display: none;
width: 100vw;
height: 100vh;
text-align: center;
position: fixed;
top: 0;
left: 0;
z-index: 10;
}
.dialog-box {
top:10vh;
left:10vw;
width: 80vw;
height: 80vh;
text-align: left;
position: absolute;
border: 1px solid #ccc;
display: flex;
flex-direction: column;
}
.dialog-title {
line-height: 28px;
padding-left: 5px;
padding-right: 5px;
border-bottom: 1px solid #ccc;
font-size: 12px;
text-align: left;
}
.dialog-close {
position: absolute;
top: 5px;
right: 5px;
font-size: 12px;
}
.dialog-body {
flex:1;
overflow: auto;
}
</
style
>
</
head
>
<
body
>
<
button
onclick
=
"$('#dialogContainer').show();"
>點擊顯示彈出框</
button
>
<
div
id
=
"dialogContainer"
class
=
"dialog-container"
>
<
div
class
=
"dialog-box"
>
<
div
class
=
"dialog-title"
>居中彈出框</
div
>
<
a
onclick
=
"$('#dialogContainer').hide();"
class
=
"dialog-close"
>關閉</
a
>
<
div
class
=
"dialog-body"
>
<
img
src
=
"logo.png"
class
=
"demo-image"
/>
</
div
>
</
div
>
</
div
>
</
body
>
</
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
59
60
61
62
63
64
|
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>hangge.com</
title
>
<
script
type
=
"text/javascript"
src
=
"js/jquery.js"
></
script
>
<
style
>
html, body, div, span, button {
margin: 0;
padding: 0;
border: 0;
}
button {
width: 120px;
height: 30px;
color: #FFFFFF;
font-family: "微軟雅黑";
font-size: 14px;
background: #28B995;
}
.dialog-container {
display: none;
width: 100vw;
height: 100vh;
text-align: center;
position: fixed;
top: 0;
left: 0;
z-index: 10;
}
.dialog-container:after {
display: inline-block;
content: '';
width: 0;
height: 100%;
vertical-align: middle;
}
.dialog-box {
display: inline-block;
text-align: left;
vertical-align: middle;
position: relative;
}
.demo-image {
max-width: 90vw;
max-height: 90vh;
}
</
style
>
</
head
>
<
body
>
<
button
onclick
=
"$('#dialogContainer').show();"
>點擊顯示大圖</
button
>
<
div
id
=
"dialogContainer"
class
=
"dialog-container"
onclick
=
"$('#dialogContainer').hide();"
>
<
div
class
=
"dialog-box"
>
<
img
src
=
"image.jpg"
class
=
"demo-image"
/>
</
div
>
</
div
>
</
body
>
</
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
59
60
61
62
|
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>hangge.com</
title
>
<
script
type
=
"text/javascript"
src
=
"js/jquery.js"
></
script
>
<
style
>
html, body, div, span, button {
margin: 0;
padding: 0;
border: 0;
}
body {
}
page {
display: block;
height: 98vh;
width: 69.3vh;
margin: 1vh auto;
padding: 12vh;
border: 1px solid #646464;
box-shadow: 0 0 15px rgba(0,0,0,.75);
box-sizing: border-box;
position: relative;
}
page:after {
content: attr(data-page);
color: graytext;
font-size: 12px;
text-align: center;
bottom: 4vh;
position: absolute;
left: 10vh;
right: 10vh;
}
a {
color: #34538b;
font-size: 14px;
}
</
style
>
<
script
type
=
"text/javascript"
>
$(document).ready(function(){
var lenPage = $("page").length;
//自動添加每頁底部的頁碼
$("page").each(function(i){
$(this).attr("data-page", "第 "+ (i+1) +" 頁,共 "+ lenPage +" 頁");
});
});
</
script
>
</
head
>
<
body
>
<
page
></
page
>
<
page
></
page
>
</
body
>
</
html
>
|
原文出自:www.hangge.com 轉載請保留原文連接:http://www.hangge.com/blog/cache/detail_1715.htmljavascript