|
|||
Flex Layout nicht auf volle Höhe
Ich hätte gerne ein ganz simples Layout. 4 Divs die jeweils ein viertel des Bildschirms völlig ausfüllen.
Zur Breite hin funktioniert das auch gut, jedoch nicht in der höhe. Warum funktioniert der Befehl Height: 100% nicht? Edit fiddle - JSFiddle |
Sponsored Links |
Sponsored Links |
|
|||
Hallo,
mir erscheint die Lösung ganz normal mit height am einfachsten. HTML-Code:
<body> <main role="main"> <div> <p>div 1</p> </div> <div> <p>div 2</p> </div> <div> <p>div 3</p> </div> <div> <p>div 4</p> </div> </main> </body> Mit float würde das CSS folgendermaßen aussehen (clear durch ein hinterlegtes clearfix an anderer Stelle): Code:
html { height: 100%; border: 3px solid green; } body { height: 100%; border: 3px solid red; } main { height: 100%; border: 3px solid orange; } div { width: 50%; height: 50%; float: left; border: 3px solid blue; } und mit dem Flexbox-Modell folgendermaßen: Code:
html { height: 100%; border: 3px solid green; } body { height: 100%; border: 3px solid red; } main { height: 100%; border: 3px solid orange; display: flex; flex-wrap: wrap; } div { width: 50%; height: 50%; border: 3px solid blue; } Gruss MrMurphy Geändert von MrMurphy (14.11.2014 um 06:34 Uhr) |
|
||||
Zitat:
Hier auf die Schnelle die Beide Varianten, basierend auf Deinem Quellcode: CSS-Table: HTML-Code:
<!doctype html> <meta charset="UTF-8"> <title>MichaelA :: xhtmlforum.de</title> <style> * { margin: 0; padding: 0; } html, body { height: 100%; } #editorSplitter { display: table; table-layout: fixed; width: 100%; height: 100%; } #editorSplitter > div { display: table-row; } #editorSplitter div div { display: table-cell; vertical-align: middle; text-align: center; } .red { background-color: red; } .blue { background-color: blue; } .yellow { background-color: yellow; } .green { background-color: green; } </style> <div id="editorSplitter"> <div> <div class="red">Container 1</div> <div class="yellow">Container 2</div> </div> <div> <div class="green">Container 3</div> <div class="blue">Container 4</div> </div> </div> HTML-Code:
<!doctype html> <meta charset="UTF-8"> <title>MichaelA :: xhtmlforum.de</title> <style> * { margin: 0; padding: 0; } .fullheight { position: absolute; width: 100%; min-height:100%; } .red { background-color: red; } .blue { background-color: blue; } .yellow { background-color: yellow; } .green { background-color: green; } </style> <div id="editorSplitter" class="fullheight" style="display:flex;"> <div style="flex: 1; display: flex; flex-direction: column"> <div id="pane-lt" class="red" style="flex: 1;">Container 1</div> <div id="pane-lb" class="yellow" style="flex: 1;">Container 2</div> </div> <div style="flex: 1; display: flex; flex-direction: column"> <div id="pane-rt" class="green" style="flex: 1;">Container 3</div> <div id="pane-rb" class="blue" style="flex: 1;">Container 4</div> </div> </div> Geändert von etux (17.11.2014 um 10:39 Uhr) |
|
|
Ähnliche Themen | ||||
Thema | Autor | Forum | Antworten | Letzter Beitrag |
Liquid Layout: Feste Höhe | rezilade | CSS | 1 | 11.08.2010 22:19 |
Höhe in einem dreispaltigen Layout | sliver2203 | CSS | 4 | 24.02.2009 10:55 |
Dynamische Layout Breite und Höhe | altes-kind | CSS | 7 | 12.01.2007 11:54 |
layout problem mit höhe | Deude | CSS | 6 | 31.03.2005 21:00 |
3 spalten layout - immer auf gleiche höhe "auffüllen&qu | dimension | CSS | 2 | 22.09.2004 12:02 |