Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Titre du document</title> <style> .box1 { grid-area: 1 / 1 / 2 / 2; } .box2 { grid-area: 1 / 2 / 2 / 3; } .box3 { grid-area: 1 / 3 / 2 / 4; } .box4 { grid-area: 2 / 1 / 3 / 2; } .box5 { grid-area: 2 / 2 / 3 / 3; } .box6 { grid-area: 2 / 3 / 3 / 4; } .black-box1 { grid-area: 1 / 1 / 2 / 2; } .black-box2 { grid-area: 1 / 2 / 2 / 3; } .black-box3 { grid-area: 1 / 3 / 2 / 4; } .black-box4 { grid-area: 2 / 1 / 3 / 2; } .black-box5 { grid-area: 2 / 2 / 3 / 3; } .black-box6 { grid-area: 2 / 3 / 3 / 4; } .auto-box1 { grid-area: 1 / 1 / 2 / 2; } .auto-box2 { grid-area: 1 / 2 / 2 / 3; } .auto-box3 { grid-area: 1 / 3 / 2 / 4; } .auto-box4 { grid-area: 2 / 1 / 3 / 2; } .auto-box5 { grid-area: 2 / 2 / 3 / 3; } .auto-box6 { grid-area: 2 / 3 / 3 / 4; } .grid-container { display: grid; grid-auto-columns: 50px; grid-gap: 10px; background-color: #555; padding: 10px; } .grid-container > div { background-color: #ccc; text-align: center; padding: 20px 0; font-size: 30px; } .black-container { display: grid; grid-auto-columns: 100px; grid-gap: 10px; background-color: #000; padding: 10px; } .black-container > div { background-color: #ccc; text-align: center; padding: 20px 0; font-size: 30px; } .auto-container { display: grid; grid-auto-columns: auto; grid-gap: 10px; background-color: #ccc; padding: 10px; } .auto-container > div { background-color: #999; text-align: center; padding: 20px 0; font-size: 30px; } </style> </head> <body> <h2>Exemple de la propriété grid-auto-columns</h2> <h3>50 pixels</h3> <div class="grid-container"> <div class="box1">1</div> <div class="box2">2</div> <div class="box3">3</div> <div class="box4">4</div> <div class="box5">5</div> <div class="box6">6</div> </div> <h3>100 pixels</h3> <div class="black-container"> <div class="black-box1">1</div> <div class="black-box2">2</div> <div class="black-box3">3</div> <div class="black-box4">4</div> <div class="black-box5">5</div> <div class="black-box6">6</div> </div> <h3>auto</h3> <div class="auto-container"> <div class="auto-box1">1</div> <div class="auto-box2">2</div> <div class="auto-box3">3</div> <div class="auto-box4">4</div> <div class="auto-box5">5</div> <div class="auto-box6">6</div> </div> </body> </html><!DOCTYPE html> <html> <head>