I have 2 divs on the webpage, the flipbook that is created using turnjs and another div containing the buttons. When I load the page, the divs are in the center of the page: https://imgur.com/a/lLb2g2l . After I refresh the page, the divs will shift up and stay there even after refreshing the page. This is how the page looks after refreshing: https://imgur.com/a/guwW0RT .
This is the html:
JavaScript
x
85
85
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
3
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
4
<head>
5
<script type="text/javascript" src="js/jquery.min.js"></script>
6
<script type="text/javascript" src="js/turn.min.js"></script>
7
<link rel="stylesheet" href="css/test.css" />
8
</head>
9
<body>
10
11
<div class="flipbook-viewport">
12
<div class="container">
13
<div class="flipbook">
14
<div style="background-image:url(brochure/Brochure_Main.jpeg)"></div>
15
<div style="background-image:url(brochure/Brochure_Mobile_Ordering.jpg)"></div>
16
<div style="background-image:url(brochure/Brochure_POS_Automobile.jpg)"></div>
17
<div style="background-image:url(brochure/Brochure_POS_Beauty_Wellness.jpg)"></div>
18
<div style="background-image:url(brochure/Brochure_POS_Food_Beverage.jpg)"></div>
19
<div style="background-image:url(brochure/Brochure_POS_Hair_Salon.jpg)"></div>
20
<div style="background-image:url(brochure/Brochure_POS_Minimart.jpg)"></div>
21
<div style="background-image:url(brochure/Brochure_POS_Mobile_Phone_Shop.jpg)"></div>
22
<div style="background-image:url(brochure/Brochure_POS_Retail.jpg)"></div>
23
<div style="background-image:url(brochure/Brochure_POS_Wholesale.jpg)"></div>
24
</div>
25
</div>
26
</div>
27
28
<div class="buttons">
29
<button type="button" onclick="thePreviousPage()" class="button">Previous</button>
30
<button type="button" onclick="theHomePage()" class="button">Home</button>
31
<button type="button" onclick="theNextPage()" class="button">Next</button>
32
</div>
33
34
35
<script type="text/javascript">
36
theWindowHeight = $(window).height();
37
theWindowWidth = $(window).width();
38
// Create the flipbook
39
40
$('.flipbook').turn({
41
42
// Width
43
44
width: theWindowWidth*0.9,
45
46
// Height
47
48
height:theWindowHeight*0.7,
49
50
// Elevation
51
52
elevation: 50,
53
54
// Enable gradients
55
56
gradients: true,
57
58
// Auto center this flipbook
59
60
autoCenter: true
61
62
});
63
64
console.log($('.flipbook').turn('size'));
65
66
function thePreviousPage()
67
{
68
$('.flipbook').turn('previous');
69
}
70
71
function theHomePage()
72
{
73
$('.flipbook').turn('page',1);
74
}
75
76
function theNextPage()
77
{
78
$('.flipbook').turn('next');
79
}
80
81
</script>
82
83
</body>
84
</html>
85
This is the css:
JavaScript
1
79
79
1
body{
2
overflow:hidden;
3
background-color:#fcfcfc;
4
margin:0;
5
padding:0;
6
7
}
8
9
.flipbook-viewport{
10
overflow:hidden;
11
width:100%;
12
height:100% !important;
13
overflow-anchor: none;
14
15
}
16
17
.flipbook-viewport .container{
18
position: absolute;
19
margin: auto;
20
top: 45%;
21
left: 37%;
22
height: 100%;
23
width: 100%;
24
}
25
26
.flipbook-viewport .flipbook{
27
top: -30%;
28
left: -32%;
29
}
30
31
.flipbook
32
{
33
transform: translate(-50%, -50%);
34
}
35
36
.flipbook-viewport .page{
37
background-color:white;
38
background-repeat:no-repeat;
39
background-size:100% 100%;
40
}
41
42
.flipbook .page{
43
-webkit-box-shadow:0 0 20px rgba(0,0,0,0.2);
44
-moz-box-shadow:0 0 20px rgba(0,0,0,0.2);
45
-ms-box-shadow:0 0 20px rgba(0,0,0,0.2);
46
-o-box-shadow:0 0 20px rgba(0,0,0,0.2);
47
box-shadow:0 0 20px rgba(0,0,0,0.2);
48
}
49
50
.flipbook-viewport .page img{
51
-webkit-touch-callout: none;
52
-webkit-user-select: none;
53
-khtml-user-select: none;
54
-moz-user-select: none;
55
-ms-user-select: none;
56
user-select: none;
57
margin:0;
58
}
59
60
.flipbook-viewport .shadow{
61
-webkit-transition: -webkit-box-shadow 0.5s;
62
-moz-transition: -moz-box-shadow 0.5s;
63
-o-transition: -webkit-box-shadow 0.5s;
64
-ms-transition: -ms-box-shadow 0.5s;
65
66
-webkit-box-shadow:0 0 20px #ccc;
67
-moz-box-shadow:0 0 20px #ccc;
68
-o-box-shadow:0 0 20px #ccc;
69
-ms-box-shadow:0 0 20px #ccc;
70
box-shadow:0 0 20px #ccc;
71
}
72
73
.button{
74
position: absolute;
75
align-items: center;
76
left: 50%;
77
bottom: 10%;
78
}
79
How do I ensure that the contents will not shift up after the page refreshes?
Advertisement
Answer
You just need to do some css updates, here are the few css classes are updated,
JavaScript
1
21
21
1
.flipbook-viewport {
2
overflow: hidden;
3
width: 100%;
4
height: 100% !important;
5
overflow-anchor: none;
6
top: 100px;
7
position: relative;
8
}
9
.flipbook-viewport .container {
10
position: relative;
11
margin: auto;
12
top: 45%;
13
left: 37%;
14
height: 100%;
15
width: 100%;
16
}
17
.flipbook-viewport .flipbook {
18
left: auto;
19
top: auto;
20
}
21