Beispiel:Box-Modell-2.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Box-Modell - 2</title>
  <style>
h1, p {
	margin: 30px;
	border: 10px solid steelblue;
	padding: 10px;
	background: #f2dea6;      /* färbt padding und content */
}

.box {
	width: 200px;
	height: 50px;
	margin: 20px auto;
}
.box .content {
	display: inline-block;  /* nötig, damit span eine width akzeptiert */
	width: 100%;
    height: 100%;
	background: #641702;    /* visualisiert content-box */
	color: white;
	text-align: center;     /* Inhalt hor. + vert. zentrieren */
	align-content: center;
}
  </style>
</head>
<body>
<h1>Überschrift</h1>
<p class="box">
  <span class="content">Das ist der Inhalt der Box.</span>
</p>

<p>Das ist ein weiterer Textabsatz.</p>

</body>
</html>