Beispiel:CSS-Flexbox-6a.html
Aus SELFHTML-Wiki
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css">
<title>Flexbox - Breiten mit flex</title>
<style>
.flex-container {
display: flex;
border: 2px dotted;
margin-bottom: 1em;
}
.flex-item {
flex: 1 1 0%;
border: 1px solid;
border-radius: 0 .5em .5em;
margin: .5em;
padding: .5em;
background: #ffebe6;
}
.ausnahme1 {
flex: 2 1 0%;
}
.ausnahme2 {
flex: 3 1 0%;
}
p.flex-item {
font-weight: bold;
text-align: center;
}
.flex-item:nth-of-type(2) {
background: #fdfcf3;
}
.flex-item:nth-of-type(3) {
background: #ebf5d7;
}
.flex-item:nth-of-type(4) {
background: #e6f2f7;
}
.flex-item:nth-of-type(5) {
background: hsla(277, 53%, 73%,0.3) ;
}
</style>
</head>
<body>
<h1>Flexbox - unterschiedliche Breiten</h1>
<main>
<p>Durch die Eigenschaft <code>flex</code> können Sie für die <em>Flex-Items</em> unterschiedliche Breiten festlegen.<br>
Wie groß diese genau dargestellt werden, entscheidet der Browser.</p>
<div class="flex-container">
<p class="flex-item">1</p>
<p class="flex-item">2</p>
<p class="flex-item">3</p>
<p class="flex-item">4</p>
<p class="flex-item">5</p>
</div>
<div class="flex-container">
<p class="flex-item">1</p>
<p class="flex-item ausnahme1">2</p>
<p class="flex-item ausnahme2">3</p>
<p class="flex-item">4</p>
<p class="flex-item">5</p>
</div>
<div class="flex-container">
<p class="flex-item">1</p>
<p class="flex-item ausnahme2">2</p>
<p class="flex-item">3</p>
<p class="flex-item">4</p>
<p class="flex-item">5</p>
</div>
</main>
</body>
</html>