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 100 101 102 103 104 105 106 107 108 109 110
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Trame Layout FLEX/GRID</title>
<meta name="Author" content="NoSmoking">
<meta name="DVP-discussion" content="dxxxxxxx">
<meta name="category" content="css">
<meta name="description" content="Application modèle Flexbox ou modèle Grille sur élément.">
<style>
html, body {
margin: 0;
padding: 0;
font: 1em/1.5 Verdana,sans-serif;
}
body {
margin: .5em;
}
#grid-on:checked ~ .conteneur {
display: grid;
grid-template-columns: 2fr 1fr;
gap: .5em;
}
#flex-on:checked ~ .conteneur {
display: flex;
gap: .5em;
main {
flex: 2;
}
aside {
flex: 1;
}
}
header {
background-color: #FFD;
}
[type="checkbox"] {
width: 1em;
height: 1em;
margin: .5em;
font-size: 1.5em;
vertical-align: sub;
cursor: pointer;
}
main {
background-color: #EFD;
}
aside {
position: sticky;
top: 1em;
height: 80vh;
overflow-y: scroll;
background-color: #DEF;
}
footer {
background-color: #FDE;
}
aside h2 {
position: sticky;
top: 0;
margin: 0;
background: #BCD;
}
p {
margin: 4em 2em;
}
</style>
</head>
<body>
<header>
<h1>header</h1>
</header>
<input id="flex-on" type="checkbox" checked><label for="flex-on">Active le modèle Flexbox</label>
<input id="grid-on" type="checkbox"><label for="grid-on">Active le modèle Grilles</label>
<div class="conteneur">
<main>
<h2>main</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<p>Vestibulum ultricies laoreet orci, sit amet molestie nulla efficitur ac.
<p>Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
<p>Maecenas tellus elit, suscipit at laoreet et, tempor a orci.
<p>Nulla in tortor nec est placerat condimentum in nec magna.
<p>Nunc sollicitudin sem eget purus ultrices, bibendum pharetra augue aliquet.
<p>Mauris consectetur lectus ut laoreet finibus.
<p>In gravida, massa eget tempus fringilla, eros nisi gravida massa, at accumsan massa nisl vel quam.
<p>Donec maximus molestie enim, ac elementum nisi posuere a.
<p>Vivamus eu varius erat.
</main>
<aside>
<h2>aside</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<p>Vestibulum ultricies laoreet orci, sit amet molestie nulla efficitur ac.
<p>Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
<p>Maecenas tellus elit, suscipit at laoreet et, tempor a orci.
<p>Nulla in tortor nec est placerat condimentum in nec magna.
<p>Nunc sollicitudin sem eget purus ultrices, bibendum pharetra augue aliquet.
<p>Mauris consectetur lectus ut laoreet finibus.
<p>In gravida, massa eget tempus fringilla, eros nisi gravida massa, at accumsan massa nisl vel quam.
<p>Donec maximus molestie enim, ac elementum nisi posuere a.
<p>Vivamus eu varius erat.
</aside>
</div>
<footer>
<h2>footer</h2>
</footer>
</body>
</html> |
Partager