Próbálja ki Ön is →
<!DOCTYPE html>
<html>
<head>
<style>
.flex-container {
display: flex;
flex-wrap: nowrap;
background-color: DodgerBlue;
}
.flex-container > div {
background-color: #f1f1f1;
width: 100px;
margin: 10px;
text-align: center;
line-height: 75px;
font-size: 30px;
}
</style>
</head>
<body>
<h1>Flexible Boxes</h1>
<div class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
</div>
<p>Try to resize the browser window.</p>
<p>A container with "flex-wrap: nowrap;" will never wrap its items.</p>
<p><strong>Note:</strong> Flexbox is not supported in Internet Explorer 10 or earlier versions.</p>
</body>
</html>
A Flexbox Layout modul előtt négy elrendezési mód volt:
Blokkszerű, egy weboldal szakaszaihoz
Inline, szöveghez
Táblázat, kétdimenziós táblázatadatokhoz
Pozícionált, egy elem explicit helyzetére
A Flexible Box Layout Module megkönnyíti a rugalmas, érzékeny elrendezési struktúra tervezését lebegés vagy pozicionálás nélkül.
A flexbox tulajdonságait minden modern böngésző támogatja.
29.0 | 11.0 | 22.0 | 10 | 48 |
A Flexbox modell használatának megkezdéséhez először meg kell határoznia egy rugalmas tárolót.
A fenti elem egy flexibilis tárolót (a kék területet) ábrázol három rugalmas elemmel.
Rugalmas konténer három rugalmas elemmel:
<div
class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
Próbálja ki Ön is →
<!DOCTYPE html>
<html>
<head>
<style>
.flex-container {
display: flex;
background-color: DodgerBlue;
}
.flex-container > div {
background-color: #f1f1f1;
margin: 10px;
padding: 20px;
font-size: 30px;
}
</style>
</head>
<body>
<h1>Create a Flex Container</h1>
<div class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
<p>A Flexible Layout must have a parent element with the <em>display</em> property set to <em>flex</em>.</p>
<p>Direct child elements(s) of the flexible container automatically becomes flexible items.</p>
</body>
</html>
A következő fejezetekben többet megtudhat a hajlékony konténerekről és a rugalmas elemekről.