-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathratio.html
60 lines (48 loc) · 1.27 KB
/
ratio.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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 20vw;
background-color: #eee;
margin: 1rem auto;
}
.ratio {
width: 100%;
position: relative;
}
.ratio::after {
content: "";
display: block;
padding-top: calc(100% * var(--y) / var(--x));
}
.ratio-body {
width: 100%;
height: 100%;
position: absolute !important;
left: 0;
top: 0;
bottom: 0;
right: 0;
}
</style>
</head>
<body>
<div class="container">
<div class="ratio" style="--x:2;--y:1">
<div class="ratio-body">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Culpa amet beatae est in, ab fugit quis, at
qui, labore architecto blanditiis aliquam commodi repellat quisquam rem recusandae ad provident
deserunt.
</div>
</div>
</div>
</body>
</html>