forked from eracom/exemples-javascript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflexbox.html
60 lines (50 loc) · 1.03 KB
/
flexbox.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
<!doctype html>
<html>
<head>
<title>flexbox</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
height: 100vh;
font-family: "Roboto Mono", monospace;
}
.text {
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
height: 100%;
width: 100%;
position: absolute;
top: 0;
}
h1, p {
color: fuchsia;
display: inline-table;
margin: auto; /* = produit le centrage */
background: rgba(0,0,0,0.3);
padding: 0.2em 0.3em;
}
h1 {
margin-bottom: 0;
}
p {
margin-top: 1em;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
</style>
</head>
<body>
<img src="cat.jpg">
<div class="text">
<h1>At the center</h1>
<p>Automatically centered because of the flex property</p>
</div>
</body>
</html>