Beispiel:CSS2 display-table-cell.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!DOCTYPE html>
<html> 
	<head> 
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link rel="stylesheet" type="text/css" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css" />
		<title>Raster-Layout display:table-cell</title>
		<style>
			body { 
				margin: 0 auto; 
			}
			div.table {
				display: table;
				width: calc(100% - 10px);
				border: 1px solid blue;
				padding: 5px;
			}
			div.spalte { 
				display: table-cell; 
				border: thin solid red; 
				width: 200px;
				padding: 5px;
			}
		</style> 
	</head>
	<body>
		<h1>Raster-Layout display:table-cell</h1>
		<main>
			<div class="table">
				<div class="spalte">Ich bin eine Spalte.</div>
				<div class="spalte">Ich bin eine zweite Spalte.</div>
				<div class="spalte">Ich bin eine dritte Spalte mit noch mehr Inhalt.</div>
				<div class="spalte">Ich bin eine vierte Spalte.
					<br>
					<br> 
					Ein Vorteil von display:table ist, dass sich dass Layout der Spalten automatisch an die Höhe der Spalten anpasst.
				</div>
			</div>  
		</main>
	</body>
</html>