Home > Web Front-end > JS Tutorial > jquery implementation of pop-up layer effect example_jquery

jquery implementation of pop-up layer effect example_jquery

WBOY
Release: 2016-05-16 15:58:17
Original
1132 people have browsed it

The example in this article describes how jquery implements the pop-up layer effect. Share it with everyone for your reference. The specific implementation method is as follows:

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

86

87

88

89

90

91

92

93

94

95

96

97

98

99

<head runat="server">

<title>jQuery弹出层</title>

<script type="text/javascript" src="js/jquery-1.3.2-min.js"></script>

<script type="text/javascript">

 $(function() {

  $("#btnShow").click(function() {

  // var str = "我是弹出对话框";

  // $(".form").html(str);

  $("#BgDiv").css({ display: "block", height: $(document).height()});

  var yscroll = document.documentElement.scrollTop;

  $("#DialogDiv").css("top", "100px");

  $("#DialogDiv").css("display", "block");

  document.documentElement.scrollTop = 0;

  });

  $("#btnClose").click(function() {

  $("#BgDiv").css("display", "none");

  $("#DialogDiv").css("display", "none");

  });

 });

</script>

<style type="text/css">

 body, h2

 {

  margin: 0;

  padding: 0;

 }

 #BgDiv

 {

  background-color: #e3e3e3;

  position: absolute;

  z-index: 99;

  left: 0;

  top: 0;

  display: none;

  width: 100%;

  height: 1000px;

  opacity: 0.5;

  filter: alpha(opacity=50);

  -moz-opacity: 0.5;

 }

 #DialogDiv

 {

  position: absolute;

  width: 400px;

  left: 50%;

  top: 50%;

  margin-left: -200px;

  height: auto;

  z-index: 100;

  background-color: #fff;

  border: 1px #8FA4F5 solid;

  padding: 1px;

 }

 #DialogDiv h2

 {

  height: 25px;

  font-size: 14px;

  background-color: #8FA4F5;

  position: relative;

  padding-left: 10px;

  line-height: 25px;

 }

 #DialogDiv h2 a

 {

  position: absolute;

  right: 5px;

  font-size: 12px;

  color: #000000;

 }

 #DialogDiv .form

 {

  padding: 10px;

 }

 </style>

</head>

<body>

 <form id="form1" runat="server">

 <div id="BgDiv"></div>

 <div id="DialogDiv" style="display: none">

 <h2>

  弹出层<a href="#" id="btnClose">关闭</a></h2>

 <div class="form">

  我是弹出对话框!!<br />

  我是弹出对话框!!<br />

  我是弹出对话框!!<br />

  我是弹出对话框!!<br />

  我是弹出对话框!!<br />

  我是弹出对话框!!<br />

  我是弹出对话框!!<br />

 </div>

 </div>

 <p>

  </p>

 <p align="center">

 <input value="弹出" class="but" type="button" id="btnShow" />

 </p>

 </form>

</body>

</html>

Copy after login

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template