Skip to content

Commit f384b14

Browse files
author
Stephane Honore
committed
iframed solution
1 parent df0a8c9 commit f384b14

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

demos.html

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!DOCTYPE html>
2+
<html lang="es" dir="ltr">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Responsive Examples</title>
7+
8+
<link rel="stylesheet" href="css/vendor/reset.css">
9+
<link rel="stylesheet" href="css/main.css">
10+
11+
<link rel="preconnect" href="https://fonts.googleapis.com">
12+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
13+
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,200;0,300;0,400;0,600;0,800;1,300;1,400;1,600&display=swap" rel="stylesheet">
14+
15+
<style type="text/css">
16+
button {
17+
position: absolute;
18+
top: 0;
19+
left: 0;
20+
background: bisque;
21+
border-radius: 50px;
22+
height: 25px;
23+
}
24+
iframe {
25+
-webkit-transition: width 3s; /* For Safari 3.1 to 6.0 */
26+
transition: width 3s;
27+
border: 1px solid grey;
28+
}
29+
.minimized {
30+
width: 320px;
31+
}
32+
</style>
33+
34+
</head>
35+
<body>
36+
<button onclick="animation()">Change device size</button>
37+
<iframe src="" width="100%" height="1020px"></iframe>
38+
<script type="text/javascript">
39+
40+
const iframeElt = document.getElementsByTagName("iframe")[0]
41+
const urlSearchParams = new URLSearchParams(window.location.search);
42+
const params = Object.fromEntries(urlSearchParams.entries());
43+
44+
iframeElt.src = window.location.origin + "/section-" + params.demo + ".html"
45+
iframeElt.height = params.height
46+
47+
let animated = false;
48+
49+
function animation() {
50+
if (!animated) {
51+
animated = true
52+
iframeElt.classList.add("minimized")
53+
setTimeout(function() {
54+
iframeElt.classList.remove("minimized");
55+
setTimeout(function() {
56+
animated = false
57+
}, 3000)
58+
}, 3500);
59+
} else {
60+
animated = false
61+
iframeElt.classList.remove("minimized");
62+
}
63+
}
64+
65+
</script>
66+
</body>
67+
</html>

section-two.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<link rel="preconnect" href="https://fonts.googleapis.com">
1212
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
1313
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,200;0,300;0,400;0,600;0,800;1,300;1,400;1,600&display=swap" rel="stylesheet">
14-
1514
</head>
1615
<body>
1716
<section id="two">

0 commit comments

Comments
 (0)