<!DOCTYPE html>
    <html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
    <head>
<title>Sử dụng bố cục trang Flexbox trong CSS</title>
<meta name="description" content="Sử dụng bố cục trang Flexbox trong CSS - Savefile - Tin Tức -...">
<meta name="author" content=".: Nguoicodonvn2008.info - Cõi lòng người cô đơn :.">
<meta name="copyright" content=".: Nguoicodonvn2008.info - Cõi lòng người cô đơn :. [admin@nguoicodonvn2008.info]">
<meta name="robots" content="index, archive, follow, noodp">
<meta name="googlebot" content="index,archive,follow,noodp">
<meta name="msnbot" content="all,index,follow">
<meta name="generator" content="NukeViet v4.5">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="Sử dụng bố cục trang Flexbox trong CSS">
<meta property="og:type" content="website">
<meta property="og:description" content="Savefile - Tin Tức - https&#x3A;&#x002F;&#x002F;www.nguoicodonvn2008.info&#x002F;vi&#x002F;news&#x002F;savefile&#x002F;kien-thuc-may-tinh&#x002F;su-dung-bo-cuc-trang-flexbox-trong-css-10231.html">
<meta property="og:site_name" content=".&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.">
<meta property="og:url" content="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/su-dung-bo-cuc-trang-flexbox-trong-css-10231.html">
<link rel="shortcut icon" href="https://nguoicodonvn2008.info/favicon.ico">
<link rel="canonical" href="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/su-dung-bo-cuc-trang-flexbox-trong-css-10231.html">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/" title="Tin Tức" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/karaoke-dual/" title="Tin Tức - Karaoke Dual" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/nhac-tre/" title="Tin Tức - Nhạc trẻ" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/tru-tinh/" title="Tin Tức - Trữ tình" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/nuoc-ngoai/" title="Tin Tức - Nước ngoài" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/remix/" title="Tin Tức - Remix" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/tam-su-tinh-yeu/" title="Tin Tức - Tâm sự tình yêu" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/tho-suu-tam/" title="Tin Tức - Thơ sưu tầm" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/cuoc-song/" title="Tin Tức - Cuộc sống" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/phan-mem/" title="Tin Tức - Phần mềm" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/kien-thuc-may-tinh/" title="Tin Tức - Kiến thức máy tính" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/hoc-tap/" title="Tin Tức - Học tập" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/tai-lieu/" title="Tin Tức - Tài liệu" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/de-thi/" title="Tin Tức - Đề thi" type="application/rss+xml">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/bootstrap.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/style.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/news.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/custom.css" type="text/css">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/themes/default/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/themes/default/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/themes/default/js/custom.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/themes/default/js/bootstrap.min.js" type="text/javascript">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/themes/default/css/bootstrap.non-responsive.css">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/themes/default/css/style.css">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/themes/default/css/style.non-responsive.css">
<link rel="StyleSheet" href="https://nguoicodonvn2008.info/themes/default/css/news.css">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/themes/default/css/custom.css">
<style type="text/css">
	body{background: #fff;}
</style>
    </head>
    <body>
<div id="print">
	<div id="hd_print">
		<h2 class="pull-left">.&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.</h2>
		<p class="pull-right"><a title=".&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;." href="https://nguoicodonvn2008.info/">https://nguoicodonvn2008.info</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>Sử dụng bố cục trang Flexbox trong CSS</h1>
		<ul class="list-inline">
			<li>Thứ ba - 22/04/2025 22:26</li>
			<li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="javascript:;" onclick="window.print()">In ra</a></li>
			<li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="javascript:;" onclick="window.close()">Đóng cửa sổ này</a></li>
		</ul>
		<div class="clear"></div>
		<div id="hometext">
		</div>
				<div class="imghome">
			<img alt="Sử dụng bố cục trang Flexbox trong CSS" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-61.gif" width="460" class="img-thumbnail" />
		</div>
		<div class="clear"></div>
		<div id="bodytext" class="clearfix">
			<p style="text-align: justify;"><strong>Flexbox CSS là gì? Display flex&nbsp;</strong>chỉ là một trong số thuộc tính của flexbox CSS. Hãy cùng nhau tìm hiểu kỹ hơn về&nbsp;<strong>cách sử dụng bố cục flexbox trong CSS</strong>&nbsp;nhé!</p>

<p style="text-align: justify;">CSS Flexbox, viết tắt của mô-đun Flexible Box Layout, là một công cụ bố cục mạnh mẽ được thiết kế để đơn giản hóa bố cục trang web bằng cách sắp xếp các mục theo hàng hoặc cột một cách dễ dàng.</p>

<p style="text-align: justify;">Flexbox loại bỏ nhu cầu về các phần tử nổi hoặc định vị phức tạp, cho phép bố cục phản hồi và động.<br />
Nó căn chỉnh các mục một cách hiệu quả, phân bổ không gian trong một vùng chứa, ngay cả khi kích thước của chúng là động hoặc không xác định.<br />
Flexbox được hỗ trợ trong tất cả các trình duyệt hiện đại, khiến nó trở thành lựa chọn đáng tin cậy để tạo ra các thiết kế linh hoạt.</p>

<p style="text-align: justify;">Học Flexbox có thể không vui lúc đầu. Nó sẽ thách thức những gì bạn biết về bố cục trong CSS. Nhưng không sao cả. Mọi thứ đều đáng học hỏi.</p>

<p style="text-align: justify;">Flexbox chắc chắn là thứ bạn nên tìm hiểu nghiêm túc. Nó mở đường cho phong cách bố trí nội dung hiện đại và sẽ không biến mất trong thời gian tới. Nó đã nổi lên như một tiêu chuẩn mới. Vì vậy, hãy dang rộng vòng tay đón nhận nó!</p>

<h2 style="text-align: justify;">&nbsp;</h2>

<h2 id="mcetoc_1davnsdfk0" style="text-align: justify;">Flexbox là gì?</h2>

<p style="text-align: justify;"><img alt="" data-i="0" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox.jpg" /></p>

<p style="text-align: justify;">Flexbox hay mô hình hộp linh hoạt trong CSS là mô hình bố cục một chiều có bố cục linh hoạt và hiệu quả với không gian được phân bổ giữa các mục để kiểm soát cấu trúc căn chỉnh của chúng, tức là, đây là mô hình bố cục cung cấp cách sắp xếp các dễ dàng và rõ ràng các mục nằm trong một container. Flexbox có thể hữu ích trong việc tạo bố cục quy mô nhỏ, đáp ứng nhanh &amp; thân thiện với thiết bị di động.</p>

<div style="text-align: justify;">&nbsp;</div>

<p style="text-align: justify;">Đặc điểm nổi bật của flexbox:</p>

<ul>
	<li style="text-align: justify;">Vô cùng linh hoạt.</li>
	<li style="text-align: justify;">Sắp xếp &amp; căn chỉnh các mục.</li>
	<li style="text-align: justify;">Giãn cách phù hợp.</li>
	<li style="text-align: justify;">Sắp xếp thứ tự các mục hợp lý.</li>
	<li style="text-align: justify;">Bootstrap 4 được xây dựng dựa trên bố cục flex.</li>
</ul>

<p style="text-align: justify;">Trước mô hình flexbox, lập trình viên có 4 chế độ bố cục:</p>

<ul>
	<li style="text-align: justify;">Block được dùng để tạo các phần trong trang web.</li>
	<li style="text-align: justify;">Inline được dùng cho văn bản.</li>
	<li style="text-align: justify;">Table được dùng cho dữ liệu bảng hai chiều.</li>
	<li style="text-align: justify;">Positioned được dùng chỉ vị trí rõ ràng của một phần tử.</li>
</ul>

<p style="text-align: justify;">Hiện có hai thành phần chính trong Flexbox:</p>

<ul>
	<li style="text-align: justify;">Flex container</li>
	<li style="text-align: justify;">Flex Items</li>
</ul>

<p style="text-align: justify;"><strong>Lưu ý</strong>: Flexbox Layout phù hợp nhất để thiết lập bố cục ở quy mô nhỏ, còn thiết lập bố cục với phạm vi lớn hơn thì vẫn nên sử dụng kiểu thông thường là dàn trang theo dạng lưới (grid layout).</p>

<h2 id="mcetoc_1davnsdfk1" style="text-align: justify;">Các khái niệm cơ bản và thuật ngữ</h2>

<p style="text-align: justify;"><strong>Bố cục Flex</strong>&nbsp;được thiết lập từ một khung lớn (parent container) đóng vai trò là khung linh hoạt (flex containter) và các thẻ con ngay trong nó (immediate children) đóng vai trò các mục nhỏ linh hoạt (flex item).</p>

<p style="text-align: justify;">Dưới đây là sơ đồ cấu trúc Flexbox:</p>

<p style="text-align: justify;"><img alt="" data-i="1" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-1.jpg" data-was-processed="true" height="281" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-1.jpg" width="650" /></p>

<p style="text-align: justify;">Thành phần quan trọng nhất của Flexbox là</p>

<ul>
	<li style="text-align: justify;"><strong>container:</strong>&nbsp;là thành phần lớn bao quanh các phần tử bên trong, các item bên trong sẽ hiển thị dựa trên thiết lập của container này.</li>
	<li style="text-align: justify;"><strong>item:</strong>&nbsp;là phần tử con của container, bạn có thể thiết lập nó sẽ sử dụng bao nhiêu cột trong một container, hoặc thiết lập thứ tự hiển thị của nó.</li>
</ul>

<table>
	<tbody>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="2" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-2.jpg" data-was-processed="true" height="143" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-2.jpg" width="318" /></td>
			<td style="text-align: justify;"><img alt="" data-i="3" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-3.jpg" data-was-processed="true" height="143" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-3.jpg" width="320" /></td>
		</tr>
	</tbody>
</table>

<p style="text-align: justify;">Các item sẽ được bố trí theo trục main axis (bắt đầu từ main-start, kết thúc ở main-end) hoặc theo trục cross axis (bắt đầu từ cross-start, kết thúc ở cross-end).</p>

<div style="text-align: justify;">&nbsp;</div>

<ul>
	<li style="text-align: justify;"><strong>main axis:</strong>&nbsp;đây là trục chính để điều khiển hướng mà các item sẽ hiển thị.&nbsp;<strong>Lưu ý</strong>, main axis không phải lúc nào cũng nằm ngang như sơ đồ trên, bạn có thể sử dụng thuộc tính flex-direction để thay đổi hướng của trục và lúc đó các item sẽ hiển thị theo nó.</li>
	<li style="text-align: justify;"><strong>main-start | main-end:</strong>&nbsp;khi thiết lập flexbox, các item nằm trong container hiển thị từ điểm bắt đầu gọi là main-start tới điểm kết thúc gọi là main-end.</li>
	<li style="text-align: justify;"><strong>main size:</strong>&nbsp;kích thước (chiều rộng hoặc chiều cao) của các item, tùy thuộc vào hướng của main axis.</li>
	<li style="text-align: justify;"><strong>cross axis</strong>: cross axis luôn là trục vuông góc của main axis. Hướng của nó phụ thuộc vào hướng của main axis.</li>
	<li style="text-align: justify;"><strong>cross-start | cross-end:</strong>&nbsp;có ý nghĩa tương tự nhưng luôn vuông góc với main start, main end.</li>
	<li style="text-align: justify;"><strong>cross size:</strong>&nbsp;kích thước (chiều rộng hoặc chiều cao) của các item dựa trên trục cross axis, tùy thuộc vào hướng của main axis.</li>
</ul>

<h2 id="mcetoc_1davnsdfk2" style="text-align: justify;">Các thuộc tính của Flex Container</h2>

<p style="text-align: justify;"><img alt="" data-i="4" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-4.jpg" data-was-processed="true" height="222" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-4.jpg" width="560" /></p>

<h3 id="mcetoc_1davnsdfk3" style="text-align: justify;">display</h3>

<p style="text-align: justify;">Để sử dụng flex trong css thì đơn giản là chúng ta chỉ cần khai báo&nbsp;<strong>thuộc tính display: flex</strong></p>

<pre id="pre0" style="text-align: justify;">
.container {  display: flex; /* hoặc inline-flex */}</pre>

<p style="text-align: justify;"><strong>Lưu ý:</strong>&nbsp;các cột CSS thông thường không sử dụng được trong flex container.</p>

<h3 id="mcetoc_1davnsdfk4" style="text-align: justify;">flex-direction</h3>

<p style="text-align: justify;"><strong>Thuộc tính flex-direction</strong>&nbsp;xác định hướng của main-axis để container sắp xếp các item.</p>

<table>
	<tbody>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="5" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-5.jpg" data-was-processed="true" height="248" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-5.jpg" width="396" /></td>
			<td style="text-align: justify;"><img alt="" data-i="6" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-6.jpg" data-was-processed="true" height="313" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-6.jpg" width="248" /></td>
		</tr>
	</tbody>
</table>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre1" style="text-align: justify;">
.container {   flex-direction: row | row-reverse | column | column-reverse; }</pre>

<p style="text-align: justify;"><strong>Các tham số:</strong></p>

<ul>
	<li style="text-align: justify;"><strong>row</strong>: mặc định, flex item được sắp xếp theo chiều ngang,&nbsp;<strong>từ trái qua phải</strong>&nbsp;(main axis nằm ngang).</li>
	<li style="text-align: justify;"><strong>row-reverse:</strong>&nbsp;flex item được sắp xếp theo chiều ngang,&nbsp;<strong>từ phải qua trái</strong>&nbsp;(main axis nằm ngang).</li>
	<li style="text-align: justify;"><strong>column:</strong>&nbsp;flex item được sắp xếp theo chiều dọc,<strong>&nbsp;từ trên xuống dưới</strong>&nbsp;(main axis đứng dọc).</li>
	<li style="text-align: justify;"><strong>column-reverse:</strong>&nbsp;flex item được sắp xếp theo chiều dọc,&nbsp;<strong>từ dưới lên trên</strong>&nbsp;(main axis đứng dọc).</li>
</ul>

<p style="text-align: justify;"><strong>Ví dụ:</strong></p>

<table>
	<tbody>
		<tr>
			<td>
			<pre id="pre2" style="text-align: justify;">
.flex-container {  display: flex;  flex-direction: row;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="7" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-8.jpg" data-was-processed="true" height="61" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-8.jpg" width="400" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre3" style="text-align: justify;">
.flex-container {  display: flex;  flex-direction: row-reverse;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="8" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-9.jpg" data-was-processed="true" height="61" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-9.jpg" width="400" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre4" style="text-align: justify;">
.flex-container {  display: flex;  flex-direction: column;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="9" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-11.jpg" data-was-processed="true" height="180" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-11.jpg" width="400" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre5" style="text-align: justify;">
.flex-container {  display: flex;  flex-direction: column-reverse;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="10" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-10.jpg" data-was-processed="true" height="179" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-10.jpg" width="400" /></td>
		</tr>
	</tbody>
</table>

<div style="text-align: justify;">&nbsp;</div>

<p style="text-align: justify;">Code đầy đủ:</p>

<pre id="pre6" style="text-align: justify;">
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;style&gt;.flex-container {  display: flex;  flex-direction: column;  background-color: #e9d8f4;}.flex-container &gt; div {  background-color: #58257b;  width: 100px;  margin: 10px;  color: white;  text-align: center;  line-height: 75px;  font-size: 30px;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Thuộc tính flex-direction&lt;/h1&gt;&lt;div class=&quot;flex-container&quot;&gt;  &lt;div&gt;1&lt;/div&gt;  &lt;div&gt;2&lt;/div&gt;  &lt;div&gt;3&lt;/div&gt; &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

<h3 id="mcetoc_1davnsdfk5" style="text-align: justify;">flex-wrap</h3>

<p style="text-align: justify;"><img alt="" data-i="11" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-7.jpg" data-was-processed="true" height="185" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-7.jpg" width="400" /></p>

<p style="text-align: justify;">Theo mặc định, item sẽ tự động thay đổi kích thước phần tử để nó luôn hiển thị trên cùng một dòng dù bạn có resize trình duyệt theo kích thước nào, điều này dễ làm cho nội dung bên trong (nếu có) bị giãn hay ép nhỏ lại, có thể gây xấu giao diện.</p>

<p style="text-align: justify;">Vì vậy, ta có&nbsp;<strong>thuộc tính flex-wrap</strong>&nbsp;cho phép item tự động xuống dòng khi kích thước container thay đổi.</p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre7" style="text-align: justify;">
.container{   flex-wrap: nowrap | wrap | wrap-reverse; }</pre>

<p style="text-align: justify;"><strong>Tham số:</strong></p>

<ul>
	<li style="text-align: justify;"><strong>nowrap:&nbsp;</strong>mặc định, tất cả các item sẽ nằm trên một dòng.</li>
	<li style="text-align: justify;"><strong>wrap:&nbsp;</strong>khi kích thước container thay đổi và tổng chiều rộng các item cộng lại lớn hơn chiều rộng của container thì item sẽ tự động xuống dòng.</li>
	<li style="text-align: justify;"><strong>wrap-reverse:&nbsp;</strong>tương tự như&nbsp;<strong>wrap,</strong>&nbsp;nhưng thay vì xuống dòng thì item sẽ tự động nhảy lên trên.</li>
</ul>

<p style="text-align: justify;"><strong>Ví dụ:</strong></p>

<table>
	<tbody>
		<tr>
			<td>
			<pre id="pre8" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: nowrap;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="12" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-15.jpg" data-was-processed="true" height="97" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-15.jpg" width="394" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre9" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: wrap;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="13" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-12.jpg" data-was-processed="true" height="194" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-12.jpg" width="395" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre10" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: wrap-reverse;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="14" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-14.jpg" data-was-processed="true" height="194" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-14.jpg" width="392" /></td>
		</tr>
	</tbody>
</table>

<p style="text-align: justify;">Chạy code sau rồi thử resize trình duyệt để thấy rõ hơn sự khác biệt nhé:</p>

<pre id="pre11" style="text-align: justify;">
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;style&gt;.flex-container {  display: flex;  flex-wrap: wrap-reverse;  background-color: #e9d8f4;}.flex-container &gt; div {  background-color: #58257b;  width: 100px;  margin: 10px;  color: white;  text-align: center;  line-height: 75px;  font-size: 30px;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Thuộc tính flex-wrap&lt;/h1&gt;&lt;div class=&quot;flex-container&quot;&gt;  &lt;div&gt;1&lt;/div&gt;  &lt;div&gt;2&lt;/div&gt;  &lt;div&gt;3&lt;/div&gt;   &lt;div&gt;4&lt;/div&gt;   &lt;div&gt;5&lt;/div&gt; &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

<h3 id="mcetoc_1davnsdfk6" style="text-align: justify;">flex-flow</h3>

<p style="text-align: justify;"><strong>Thuộc tính flex-flow</strong>&nbsp;sử dụng để gộp chung hai thuộc tính flex-direction và flex-wrap.</p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre12" style="text-align: justify;">
flex-flow: &lt;&#039;flex-direction&#039;&gt; || &lt;&#039;flex-wrap&#039;&gt;</pre>

<p style="text-align: justify;"><strong>Ví dụ:</strong></p>

<pre id="pre13" style="text-align: justify;">
.flex-container {  display: flex;  flex-flow: row wrap;}</pre>

<h3 id="mcetoc_1davnsdfk7" style="text-align: justify;">justify-content</h3>

<table>
	<tbody>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="15" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-13.jpg" data-was-processed="true" height="75" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-13.jpg" width="310" /></td>
			<td style="text-align: justify;"><img alt="" data-i="16" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-16.jpg" data-was-processed="true" height="79" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-16.jpg" width="310" /></td>
		</tr>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="17" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-17.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-17.jpg" /></td>
			<td style="text-align: justify;"><img alt="" data-i="18" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-18.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-18.jpg" /></td>
		</tr>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="19" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-19.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-19.jpg" /></td>
			<td style="text-align: justify;"><img alt="" data-i="20" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-20.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-20.jpg" /></td>
		</tr>
	</tbody>
</table>

<p style="text-align: justify;">Theo mặc định, các item bên trong sẽ bắt đầu từ main start đến main end, tuy nhiên, đôi khi container vẫn còn khoảng trống. Vì vậy, bạn có thể sử dụng&nbsp;<strong>thuộc tính justify-content</strong>&nbsp;để điều chỉnh vị trí bắt đầu và căn chỉnh các item bên trong container theo&nbsp;<strong>dọc theo trục main axis</strong>, chiều ngang hoặc chiều dọc tùy thuộc vào flex-direction.</p>

<div style="text-align: justify;">&nbsp;</div>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre14" style="text-align: justify;">
.container {  justify-content: flex-start | flex-end | center | space-between |                   space-around | space-evenly; }</pre>

<p style="text-align: justify;"><strong>Các tham số:</strong></p>

<ul>
	<li style="text-align: justify;"><strong>flex-start:&nbsp;</strong>giá trị mặc định, item sẽ bắt đầu từ lề chính<strong>&nbsp;main-start</strong>&nbsp;của container.</li>
	<li style="text-align: justify;"><strong>flex-end:</strong>&nbsp;item sẽ bắt đầu từ lề chính<strong>&nbsp;main-end</strong>&nbsp;của container (khác với row-reverse là đổi hướng hiển thị).</li>
	<li style="text-align: justify;"><strong>center:</strong>&nbsp;item sẽ nằm giữa container.</li>
	<li style="text-align: justify;"><strong>space-between:</strong>&nbsp;các item sẽ có khoảng cách giữa các phần tử bằng nhau do container sẽ tự động căn khoảng cách, item đầu tiên sát lề chứa điểm main-start, item cuối cùng sát lề chứa điểm main-end.</li>
	<li style="text-align: justify;"><strong>space-around:</strong>&nbsp;tương tự space-between, nhưng khác ở chỗ là mỗi item có khoảng cách 2 bên cạnh và những khoảng cách này bằng nhau.</li>
	<li style="text-align: justify;"><strong>space-evenly:</strong>&nbsp;các item được phân phối sao cho khoảng cách giữa hai item bất kỳ, giữa item và các lề là bằng nhau.</li>
</ul>

<p style="text-align: justify;"><strong>Ví dụ: Ở đây main axis nằm ngang</strong></p>

<table>
	<tbody>
		<tr>
			<td>
			<pre id="pre15" style="text-align: justify;">
.flex-container {  display: flex;  justify-content: flex-start;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="21" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-21.jpg" data-was-processed="true" height="98" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-21.jpg" width="386" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre16" style="text-align: justify;">
.flex-container {  display: flex;  justify-content: flex-end;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="22" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-22.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-22.jpg" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre17" style="text-align: justify;">
.flex-container {  display: flex;  justify-content: center;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="23" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-23.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-23.jpg" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre18" style="text-align: justify;">
.flex-container {  display: flex;  justify-content: space-between;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="24" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-24.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-24.jpg" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre19" style="text-align: justify;">
.flex-container {  display: flex;  justify-content: space-evenly;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="25" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-25.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-25.jpg" /></td>
		</tr>
		<tr>
			<td>
			<pre id="pre20" style="text-align: justify;">
.flex-container {  display: flex;  justify-content: space-around;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="26" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-26.jpg" data-was-processed="true" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-26.jpg" /></td>
		</tr>
	</tbody>
</table>

<p style="text-align: justify;">Thay các giá trị vào code để thấy sự khác biệt nhé:</p>

<pre id="pre21" style="text-align: justify;">
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;style&gt;.flex-container {  display: flex;  justify-content: space-evenly;  background-color: #e9d8f4;}.flex-container &gt; div {  background-color: #58257b;  width: 60px;  margin: 10px;  color: white;  text-align: center;  line-height: 75px;  font-size: 30px;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Thuộc tính justify-content&lt;/h1&gt;&lt;div class=&quot;flex-container&quot;&gt;  &lt;div&gt;1&lt;/div&gt;  &lt;div&gt;2&lt;/div&gt;  &lt;div&gt;3&lt;/div&gt; &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

<h3 id="mcetoc_1davnsdfk8" style="text-align: justify;">align-items</h3>

<table>
	<tbody>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="27" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-27-1.jpg" data-was-processed="true" height="135" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-27-1.jpg" width="300" /></td>
			<td style="text-align: justify;"><img alt="" data-i="28" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-28-1.jpg" data-was-processed="true" height="134" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-28-1.jpg" width="149" /></td>
		</tr>
	</tbody>
</table>

<table>
	<tbody>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="29" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-28-1.jpg" data-was-processed="true" height="134" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-28-1.jpg" width="149" /></td>
			<td style="text-align: justify;"><img alt="" data-i="30" data-src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-3-1.jpg" data-was-processed="true" height="124" src="https://st.quantrimang.com/photos/image/2019/05/14/flexbox-3-1.jpg" width="300" /></td>
		</tr>
	</tbody>
</table>

<p style="text-align: justify;"><strong>Thuộc tính align-items</strong>&nbsp;sử dụng để điều chỉnh vị trí bắt đầu và căn chỉnh các item bên trong container theo dọc theo trục cross axis, chiều ngang hoặc chiều dọc tùy thuộc vào flex-direction.</p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre22" style="text-align: justify;">
.container {   align-items: stretch | flex-start | flex-end | center | baseline; }</pre>

<p style="text-align: justify;"><strong>Các tham số và ví dụ minh họa</strong></p>

<p style="text-align: justify;"><strong>stretch:&nbsp;</strong>giá trị mặc định, các phần tử sẽ được kéo dài để lấp đầy container chứa nó, nhưng sẽ ưu tiên giá trị height/width nếu có, khi đó item sẽ không cao full mà chỉ lấy giá trị height/width mà bạn set.</p>

<pre id="pre23" style="text-align: justify;">
.flex-container {  display: flex;  align-items: stretch;}</pre>

<p style="text-align: justify;"><img alt="" data-i="31" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-31.jpg" data-was-processed="true" height="204" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-31.jpg" width="647" /></p>

<p style="text-align: justify;"><strong>flex-start:</strong>&nbsp;item sẽ bắt đầu từ lề&nbsp;<strong>cross-start</strong>&nbsp;của container.</p>

<p style="text-align: justify;">Ví dụ&nbsp;<strong>trường hợp mặc định</strong>&nbsp;với main axis nằm ngang, cross axis đứng dọc, flex-direction: row thì các item sẽ bắt đầu từ trên.</p>

<pre id="pre24" style="text-align: justify;">
.flex-container {  display: flex;  align-items: flex-start;}</pre>

<p style="text-align: justify;"><img alt="" data-i="32" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-32.jpg" data-was-processed="true" height="205" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-32.jpg" width="646" /></p>

<p style="text-align: justify;"><strong>flex-end:&nbsp;</strong>item sẽ bắt đầu từ lề cross-end của container. Trường hợp mặc định với cross axis đứng dọc, flex-direction: row thì các item sẽ dồn xuống dưới.</p>

<pre id="pre25" style="text-align: justify;">
.flex-container {  display: flex;  align-items: flex-end;}</pre>

<p style="text-align: justify;"><img alt="" data-i="33" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-33.jpg" data-was-processed="true" height="204" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-33.jpg" width="645" /></p>

<div style="text-align: justify;">&nbsp;</div>

<p style="text-align: justify;"><strong>center:&nbsp;</strong>item sẽ căn giữa theo chiều của cross axis.</p>

<pre id="pre26" style="text-align: justify;">
.flex-container {  display: flex;  align-items: center;}</pre>

<p style="text-align: justify;"><img alt="" data-i="34" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-34.jpg" data-was-processed="true" height="205" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-34.jpg" width="646" /></p>

<p style="text-align: justify;"><strong>baseline:&nbsp;</strong>item được căn chỉnh theo đường cơ sở của chúng.</p>

<p style="text-align: justify;">Đường cơ sở là đường mà tất cả các chữ cái sẽ &quot;ngồi lên&quot;. Bạn có thể sử dụng kích thước font chữ khác nhau để thấy rằng các mục được căn chỉnh theo đường cơ sở baseline:</p>

<pre id="pre27" style="text-align: justify;">
.flex-container {  display: flex;  align-items: baseline;}</pre>

<p style="text-align: justify;"><img alt="" data-i="35" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-35.jpg" data-was-processed="true" height="204" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-35.jpg" width="641" /></p>

<p style="text-align: justify;">Code đầy đủ, thay các giá trị để thấy rõ hơn.</p>

<pre id="pre28" style="text-align: justify;">
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;style&gt;body { font-family: arial; }.flex-container {  display: flex;  height: 200px;  align-items: center;  background-color: #e9d8f4;}.flex-container &gt; div {  background-color: #58257b;  width: 100px;  margin: 10px;  color: white;  text-align: center;  line-height: 75px;  font-size: 30px;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Thuộc tính align-items&lt;/h1&gt;&lt;div class=&quot;flex-container&quot;&gt;  &lt;div&gt;1&lt;/div&gt;  &lt;div&gt;2&lt;/div&gt;  &lt;div&gt;3&lt;/div&gt;   &lt;div&gt;4&lt;/div&gt;   &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

<h3 id="mcetoc_1davnsdfk9" style="text-align: justify;">align-content</h3>

<table>
	<tbody>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="36" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-36.jpg" data-was-processed="true" height="148" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-36.jpg" width="350" /></td>
			<td style="text-align: justify;"><img alt="" data-i="37" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-37.jpg" data-was-processed="true" height="149" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-37.jpg" width="177" /></td>
		</tr>
	</tbody>
</table>

<table>
	<tbody>
		<tr>
			<td style="text-align: justify;"><img alt="" data-i="38" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-38.jpg" data-was-processed="true" height="148" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-38.jpg" width="173" /></td>
			<td style="text-align: justify;"><img alt="" data-i="39" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-39.jpg" data-was-processed="true" height="144" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-39.jpg" width="350" /></td>
		</tr>
	</tbody>
</table>

<p style="text-align: justify;"><strong>Thuộc tính align-content</strong>&nbsp;sử dụng để<strong>&nbsp;căn chỉnh khoảng cách</strong>&nbsp;các item bên trong container theo dọc theo trục cross axis, chiều ngang hoặc chiều dọc tùy thuộc vào flex-direction.</p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre29" style="text-align: justify;">
.container {   align-content: flex-start | flex-end | center | space-between |                  space-around | stretch; }</pre>

<p style="text-align: justify;"><strong>Các tham số:</strong></p>

<table>
	<tbody>
		<tr>
			<td>
			<p style="text-align: justify;"><strong>flex-start:</strong>&nbsp;item sẽ bắt đầu từ lề chứa cross-start của container.</p>

			<pre id="pre30" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: wrap;  align-content: flex-start;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="40" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-4-3.jpg" data-was-processed="true" height="225" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-4-3.jpg" width="300" /></td>
		</tr>
	</tbody>
</table>

<table>
	<tbody>
		<tr>
			<td>
			<p style="text-align: justify;"><strong>flex-end:</strong>&nbsp;item sẽ bắt đầu từ lề chứa cross-end của container.</p>

			<pre id="pre31" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: wrap;  align-content: flex-end;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="41" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-41.jpg" data-was-processed="true" height="226" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-41.jpg" width="300" /></td>
		</tr>
	</tbody>
</table>

<table>
	<tbody>
		<tr>
			<td>
			<p style="text-align: justify;"><strong>center:&nbsp;</strong>item sẽ nằm giữa container căn theo cross-axis.</p>

			<pre id="pre32" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: wrap;  align-content: center;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="42" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-42.jpg" data-was-processed="true" height="226" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-42.jpg" width="300" /></td>
		</tr>
	</tbody>
</table>

<table>
	<tbody>
		<tr>
			<td>
			<p style="text-align: justify;"><strong>space-between:</strong>&nbsp;các item sẽ có khoảng cách giữa các phần tử bằng nhau do container tự động căn khoảng cách, item đầu tiên sát lề chứa cross-start, item cuối cùng sát lề chứa cross-end.</p>

			<pre id="pre33" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: wrap;  align-content: space-between;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="43" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-43.jpg" data-was-processed="true" height="225" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-43.jpg" width="300" /></td>
		</tr>
	</tbody>
</table>

<table>
	<tbody>
		<tr>
			<td>
			<p style="text-align: justify;"><strong>space-around:&nbsp;</strong>tương tự space-between, nhưng khác ở chỗ là mỗi item có khoảng cách 2 bên cạnh và những khoảng cách này bằng nhau.</p>

			<pre id="pre34" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: wrap;  align-content: space-around;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="44" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-44.jpg" data-was-processed="true" height="225" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-44.jpg" width="300" /></td>
		</tr>
	</tbody>
</table>

<table>
	<tbody>
		<tr>
			<td>
			<p style="text-align: justify;"><strong>stretch</strong>: giá trị mặc định, các phần tử sẽ được kéo dài, căn chỉnh sao cho lấp đầy container chứa nó (vẫn ưu tiên giá trị height/width nếu có).</p>

			<pre id="pre35" style="text-align: justify;">
.flex-container {  display: flex;  flex-wrap: wrap;  align-content: stretch;}</pre>
			</td>
			<td style="text-align: justify;"><img alt="" data-i="45" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-45.jpg" data-was-processed="true" height="227" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-45.jpg" width="300" /></td>
		</tr>
	</tbody>
</table>

<div style="text-align: justify;">&nbsp;</div>

<p style="text-align: justify;">Code đầy đủ:</p>

<pre id="pre36" style="text-align: justify;">
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;style&gt;.flex-container {  display: flex;  height: 320px;  flex-wrap: wrap;  align-content: stretch;  background-color: #e9d8f4;}.flex-container &gt; div {  background-color: #58257b;  width: 90px;  margin: 5px;  color: white;  text-align: center;  line-height: 75px;  font-size: 30px;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Thuộc tính align-content&lt;/h1&gt;&lt;div class=&quot;flex-container&quot;&gt;  &lt;div&gt;1&lt;/div&gt;  &lt;div&gt;2&lt;/div&gt;  &lt;div&gt;3&lt;/div&gt;   &lt;div&gt;4&lt;/div&gt;  &lt;div&gt;5&lt;/div&gt;  &lt;div&gt;6&lt;/div&gt;   &lt;div&gt;7&lt;/div&gt;  &lt;div&gt;8&lt;/div&gt;   &lt;div&gt;9&lt;/div&gt;  &lt;div&gt;10&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

<h2 id="mcetoc_1davnsdfka" style="text-align: justify;">Các thuộc tính của Flex Item</h2>

<p style="text-align: justify;"><img alt="" data-i="46" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-46.jpg" data-was-processed="true" height="228" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-46.jpg" width="550" /></p>

<h3 id="mcetoc_1davnsdfkb" style="text-align: justify;">order</h3>

<p style="text-align: justify;">Theo mặc định, các item sẽ hiển thị theo thứ tự xuất hiện trong HTML, nhưng với&nbsp;<strong>thuộc tính order</strong>, bạn có thể sắp xếp lại vị trí sắp xếp của các item.</p>

<p style="text-align: justify;"><img alt="" data-i="47" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-47.jpg" data-was-processed="true" height="258" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-47.jpg" width="300" /></p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre37" style="text-align: justify;">
.item {   order: &lt;integer&gt;; /* mặc định là 0 */ }</pre>

<p style="text-align: justify;"><strong>Ví dụ:</strong></p>

<pre id="pre38" style="text-align: justify;">
&lt;div class=&quot;flex-container&quot;&gt;  &lt;div style=&quot;order: 3&quot;&gt;1&lt;/div&gt;  &lt;div style=&quot;order: 2&quot;&gt;2&lt;/div&gt;  &lt;div style=&quot;order: 4&quot;&gt;3&lt;/div&gt;   &lt;div style=&quot;order: 1&quot;&gt;4&lt;/div&gt;&lt;/div&gt;</pre>

<p style="text-align: justify;"><img alt="" data-i="48" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-48.jpg" data-was-processed="true" height="99" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-48.jpg" width="636" /></p>

<h3 id="mcetoc_1davnsdfkc" style="text-align: justify;">flex-grow</h3>

<p style="text-align: justify;"><img alt="" data-i="49" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-49.jpg" data-was-processed="true" height="119" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-49.jpg" width="300" /></p>

<p style="text-align: justify;"><strong>Thuộc tính flex-grow</strong>&nbsp;cho phép các phần tử giãn theo độ rộng của container.</p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre39" style="text-align: justify;">
.item {  flex-grow: &lt;number&gt;; /* mặc định là 0 */ }</pre>

<p style="text-align: justify;">Thuộc tính này hơi phức tạp, Quantrimang sẽ minh họa một số trường hợp hay gặp cho bạn dễ hình dung hơn. Ví dụ ta set các item có độ rộng là 100px.</p>

<p style="text-align: justify;"><img alt="" data-i="50" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-50.jpg" data-was-processed="true" height="175" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-50.jpg" width="650" /></p>

<p style="text-align: justify;">Giá trị mặc định của thuộc tính&nbsp;<strong>flex-grow là 0</strong>, các item sẽ không tự động co giãn kích thước, để lại nhiều khoảng trống trong container.</p>

<p style="text-align: justify;">Khi ta tăng&nbsp;<strong>flex-grow = 1,</strong>&nbsp;item sẽ tự động giãn ra đều nhau sao cho vừa với khung container.</p>

<p style="text-align: justify;"><img alt="" data-i="51" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-51.jpg" data-was-processed="true" height="172" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-51.jpg" width="649" /></p>

<p style="text-align: justify;">Giá trị của flex-grow rất linh động, khi set thuộc tính này cho&nbsp;<strong>tất cả các item với cùng một giá trị</strong>&nbsp;thì các item sẽ&nbsp;<strong>có tỉ lệ như nhau</strong>&nbsp;và được dàn đều lấp đầy container. Ví dụ set tất cả các phần tử flex-grow là 1 thì tất cả đều như nhau tỉ lệ 1:1, mà set flex-grow là 100 thì kết qua vẫn sẽ ra tương tự với tỉ lệ 1:1.</p>

<p style="text-align: justify;">Nhưng điều thú vị hơn ở flex-grow là áp dụng nó cho từng item. Ta có giá trị mặc định ở tất cả phần tử là flex-grow = 0, thay đổi riêng giá trị của item2 thành 1, kết quả như sau:</p>

<p style="text-align: justify;"><img alt="" data-i="52" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-52.jpg" data-was-processed="true" height="173" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-52.jpg" width="648" /></p>

<p style="text-align: justify;">Vậy là ở đây, thiết lập flex-grow là 1 thì item2 sẽ lấy phần trống còn lại của container đắp vào chính nó.</p>

<p style="text-align: justify;">Bây giờ hãy thử cho các phần tử đều là<strong>&nbsp;flex-grow: 1</strong>, nhưng set riêng phần tử thứ 3 giá trị khác:</p>

<p style="text-align: justify;"><img alt="" data-i="53" data-src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-53-1.jpg" data-was-processed="true" height="166" src="https://st.quantrimang.com/photos/image/2019/05/15/flexbox-53-1.jpg" width="648" /></p>

<p style="text-align: justify;">Lúc này thì tất cả các item đều được giãn ra lấp đầy phần trống của container, nhưng item3 có flex-grow: 3 sẽ được thừa hưởng nhiều phần trống hơn các item còn lại chỉ có flex-grow: 1, cụ thể là hơn khoảng 3 lần. Và như đã đề cập ở trên, thuộc tính flex-grow làm cho các phần tử tỉ lệ với nhau. Giả sử các item đều có flex-grow: 4 và item3 có thuộc tính flex-grow: 12 thì nó cũng tương tự như là 1 với 3.</p>

<p style="text-align: justify;">Bạn tự thay đổi các giá trị để hiểu rõ hơn nhé.</p>

<pre id="pre40" style="text-align: justify;">
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;style&gt;.flex-container {  display: flex;  align-items: stretch;  background-color: #58257b;}.flex-container&gt;div {  background-color: #e9d8f4;  color: #58257b;  margin: 5px;  text-align: center;  line-height: 75px;  font-size: 30px;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h4 style=&quot;text-align: center;&quot;&gt;#all-item: flex-grow:1|#item3: flex-grow:3&lt;/h4&gt;&lt;div class=&quot;flex-container&quot;&gt;  &lt;div style=&quot;flex-grow: 1&quot;&gt;1&lt;/div&gt;  &lt;div style=&quot;flex-grow: 1&quot;&gt;2&lt;/div&gt;  &lt;div style=&quot;flex-grow: 3&quot;&gt;3&lt;/div&gt;  &lt;div style=&quot;flex-grow: 1&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

<h3 id="mcetoc_1davnsdfkd" style="text-align: justify;">flex-shrink</h3>

<p style="text-align: justify;"><strong>Thuộc tính flex-shrink</strong>&nbsp;ngược lại với thuộc tính flex-grow ở trên, nó không giãn ra mà lại co lại khi chúng ta thay đổi độ rộng của container.</p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre41" style="text-align: justify;">
.item {   flex-shrink: &lt;number&gt;; /* mặc định là 1 */ }</pre>

<p style="text-align: justify;">Giá trị mặc định trong flex-shrink là 1, cho phép các phần tử&nbsp;<strong>co lại bằng nhau</strong>&nbsp;khi độ rộng container giảm xuống. Nếu flex-shrink: 0 thì item sẽ&nbsp;<strong>không co giãn</strong>&nbsp;mà lấy nguyên giá trị của thuộc tính width/height.</p>

<p style="text-align: justify;">Nếu muốn item3 nó co lại nhiều hơn so với các item khác thì tăng giá trị flex-shrink của nó lên.</p>

<p style="text-align: justify;"><img alt="" data-i="54" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-54.jpg" data-was-processed="true" height="169" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-54.jpg" width="581" /></p>

<p style="text-align: justify;">Resize cửa sổ trình duyệt nhỏ lại thì item3 co lại nhiều hơn:</p>

<p style="text-align: justify;"><img alt="" data-i="55" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-55.jpg" data-was-processed="true" height="169" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-55.jpg" width="437" /></p>

<h3 id="mcetoc_1davnsdfke" style="text-align: justify;">flex-basis</h3>

<p style="text-align: justify;"><strong>Thuộc tính flex-basis</strong>&nbsp;sử dụng để xác định độ dài ban đầu của một item.</p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre42" style="text-align: justify;">
.item {   flex-basis: &lt;length&gt; | auto; /* mặc định là auto */ }</pre>

<p style="text-align: justify;">Nếu bạn xác định độ dài chung của class item là 100px nhưng tùy chỉnh item3 với flex-basis: 250px thì ta sẽ được như sau:</p>

<p style="text-align: justify;"><img alt="" data-i="56" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-56.jpg" data-was-processed="true" height="175" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-56.jpg" width="650" /></p>

<h3 id="mcetoc_1davnsdfkf" style="text-align: justify;">flex</h3>

<p style="text-align: justify;"><strong>Thuộc tính flex</strong>&nbsp;sử dụng để gộp chung ba thuộc tính&nbsp;<strong>flex-grow, flex-shrink và flex-basis.</strong></p>

<p style="text-align: justify;"><strong>Cú pháp:</strong></p>

<pre id="pre43" style="text-align: justify;">
.item {   flex: none | &#91; &lt;&#039;flex-grow&#039;&gt; &lt;&#039;flex-shrink&#039;&gt; || &lt;&#039;flex-basis&#039;&gt; &#93; }</pre>

<p style="text-align: justify;">Thay vì phải sử dụng cả 3 thuộc tính:</p>

<pre id="pre44" style="text-align: justify;">
.item {   flex-grow: 1;   flex-shrink: 3;   flex-basis: 250px; }</pre>

<p style="text-align: justify;">Thì bạn có thể sử dụng thuộc tính flex một cách ngắn gọn:</p>

<pre id="pre45" style="text-align: justify;">
flex: 1 3 250px;</pre>

<p style="text-align: justify;">Giá trị mặc định của flex là:</p>

<pre id="pre46" style="text-align: justify;">
flex: 0 1 auto;</pre>

<p style="text-align: justify;"><strong>Lưu ý</strong><strong>:</strong></p>

<ul>
	<li style="text-align: justify;">Nếu thuộc tính chỉ có một tham số thế này:&nbsp;<em>flex: 1</em>; thì ta hiểu đó là<strong>&nbsp;flex-grow.</strong></li>
	<li style="text-align: justify;">Nếu thuộc tính chỉ có một tham số có đơn vị độ dài như thế này:&nbsp;<em>flex: 250px;</em>&nbsp;thì ta hiểu đó là&nbsp;<strong>flex-basis</strong>.</li>
	<li style="text-align: justify;">Nếu thuộc tính có hai tham số thế này:<em>&nbsp;flex: 1 250px;</em>&nbsp;thì ta hiểu đó là<strong>&nbsp;flex-grow và flex-basis.</strong></li>
	<li style="text-align: justify;">Nếu thuộc tính có hai tham số thế này:&nbsp;<em>flex: 1 2;</em>&nbsp;thì ta hiểu đó là&nbsp;<strong>flex-grow và flex-shrink.</strong></li>
</ul>

<h3 id="mcetoc_1davnsdfkg" style="text-align: justify;">align-self</h3>

<p style="text-align: justify;"><img alt="" data-i="57" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-57.jpg" data-was-processed="true" height="180" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-57.jpg" width="350" /></p>

<p style="text-align: justify;"><strong>Thuộc tính align-self</strong>&nbsp;có tác dụng tương tự như align-items của phần container nhưng sử dụng riêng cho từng item, bạn có thể dùng nó để đặt lại vị trí cho một số item mà align-items đã quy định.</p>

<pre id="pre47" style="text-align: justify;">
.item {   align-self: auto | flex-start | flex-end | center | baseline | stretch; }</pre>

<p style="text-align: justify;">Align-self cũng có các giá trị giống như align-items đó là:&nbsp;<strong>flex-start, flex-end, center, stretch và baseline.</strong></p>

<p style="text-align: justify;"><strong>Ví dụ:</strong>&nbsp;Ta có 5 item đã được căn ra giữa nhờ align-items:center như sau:</p>

<p style="text-align: justify;"><img alt="" data-i="58" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-59.jpg" data-was-processed="true" height="206" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-59.jpg" width="613" /></p>

<p style="text-align: justify;">Bạn có thể căn chỉnh các item theo ý thích, item1 nằm ở trên cùng, item3 thì phải kéo giãn dài ra và item5 thì phải nằm dưới cùng, hãy dùng align-self để đặt lại các vị trí.</p>

<pre id="pre48" style="text-align: justify;">
&lt;div class=&quot;flex-container&quot;&gt;  &lt;div style=&quot;align-self: flex-start&quot;&gt;1&lt;/div&gt;  &lt;div&gt;2&lt;/div&gt;  &lt;div style=&quot;align-self: stretch&quot;&gt;3&lt;/div&gt;  &lt;div&gt;4&lt;/div&gt;  &lt;div style=&quot;align-self: flex-end&quot;&gt;5&lt;/div&gt;&lt;/div&gt;</pre>

<p style="text-align: justify;"><img alt="" data-i="59" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-58.jpg" data-was-processed="true" height="207" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-58.jpg" width="634" /></p>

<h2 id="mcetoc_1davnsdfkh" style="text-align: justify;">Tạo thư viện ảnh sử dụng Flexbox</h2>

<p style="text-align: justify;">Sử dụng flexbox để tạo một bộ sưu tập ảnh hiển thị bố cục khác nhau tùy thuộc vào kích thước màn hình:</p>

<p style="text-align: justify;"><img alt="" data-i="60" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-60.jpg" data-was-processed="true" height="1126" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-60.jpg" width="650" /></p>

<p style="text-align: justify;">Bạn tự chạy code, resize màn hình để xem kết quả nhé:</p>

<pre id="pre49" style="text-align: justify;">
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;style&gt;* {  box-sizing: border-box;}body {  margin: 0;  font-family: Arial;}.header {  text-align: center;  padding: 32px;}.row {  display: flex;  flex-wrap: wrap;  padding: 0 4px;}/* Tạo bốn cột bằng nhau nằm cạnh nhau */.column {  flex: 25%;  max-width: 25%;  padding: 0 4px;}.column img {  margin-top: 8px;  vertical-align: middle;}/* Bố cục linh hoạt: tạo bố cục 2 cột */@media (max-width: 800px) {.column {  flex: 50%;  max-width: 50%;}}/* Bố cục linh hoạt: làm cho hai cột xếp chồng lên nhau thay vì cạnh nhau */@media (max-width: 600px) {.column {  flex: 100%;  max-width: 100%;}}&lt;/style&gt;&lt;body&gt;&lt;!-- Header --&gt;&lt;div class=&quot;header&quot;&gt;&lt;h1&gt;Responsive Image Grid&lt;/h1&gt;&lt;p&gt;Resize the browser window to see the responsive effect.&lt;/p&gt;&lt;/div&gt;&lt;!-- Photo Grid --&gt;&lt;div class=&quot;row&quot;&gt;   &lt;div class=&quot;column&quot;&gt;    &lt;img src=&quot;flower-1.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-1.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-2.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-2.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-3.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-3.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-4.jpg&quot; style=&quot;width:100%&quot;&gt;  &lt;/div&gt;  &lt;div class=&quot;column&quot;&gt;    &lt;img src=&quot;wedding-cake.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-4.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-5.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-5.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-6.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-6.jpg&quot; style=&quot;width:100%&quot;&gt;  &lt;/div&gt;   &lt;div class=&quot;column&quot;&gt;    &lt;img src=&quot;flower-1.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-1.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-2.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-2.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-3.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-3.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-4.jpg&quot; style=&quot;width:100%&quot;&gt;  &lt;/div&gt;  &lt;div class=&quot;column&quot;&gt;    &lt;img src=&quot;wedding-cake.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-4.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-5.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-5.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;flower-6.jpg&quot; style=&quot;width:100%&quot;&gt;    &lt;img src=&quot;wedding-6.jpg&quot; style=&quot;width:100%&quot;&gt;  &lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

<h2 id="mcetoc_1davnsdfki" style="text-align: justify;">Flexbox Layout website kiểu mẫu</h2>

<p style="text-align: justify;"><img alt="" data-i="61" data-src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-61.gif" data-was-processed="true" height="469" src="https://st.quantrimang.com/photos/image/2019/05/16/flexbox-61.gif" width="648" /></p>

<pre id="pre50" style="text-align: justify;">
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Page Title&lt;/title&gt;&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;&lt;style&gt;* {  box-sizing: border-box;}/* Style the body */body {  font-family: Arial;  padding: 10px;  background: #e9d8f4;  margin: 0;}/* Header/logo Title */.header {  padding: 10px;  text-align: center;  background: white;  color: #58257b;}.header h1 {  font-size: 40px;}.header p {  font-size: 20px;}/* Định dạng navigation bar */.navbar {  display: flex;  background-color: #58257b;}/* Định dạng link điều hướng */.navbar a {  color: #f2f2f2;  padding: 14px 20px;  text-decoration: none;  text-align: center;}/* Thay đổi màu liên kết khi di chuột qua */.navbar a:hover {  background-color: #db7093;  color: white;}/* Column container */.row {  display: flex;  flex-wrap: wrap;}/* Tạo hai cột không bằng nhau nằm cạnh nhau *//* Sidebar/Cột trái */.side {  flex: 30%;  background-color: #f1f1f1;  padding: 20px;}/* Cột chính */.main {  flex: 70%;  background-color: white;  padding: 20px;}/* Hình ảnh tượng trưng */.fakeimg {  background-color: #baa1cc;  width: 100%;  padding: 20px;}/* Footer */.footer {  padding: 10px;  text-align: center;  background: white;  margin-top: 10px;}/* Bố cục linh hoạt: các cột xếp chồng lên nhau thay vì cạnh nhau khi màn hình có chiều rộng dưới 600px */@media screen and (max-width: 600px) {  .row, .navbar {    flex-direction: column;}}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;!-- Header --&gt;&lt;div class=&quot;header&quot;&gt;  &lt;h1&gt;Website Quản Trị Mạng&lt;/h1&gt;  &lt;p&gt;Kiến thức - Kinh nghiệm - Hỏi đáp&lt;/p&gt;  &lt;p&gt;Sử dụng &lt;b&gt;flexible&lt;/b&gt; layout.&lt;/p&gt;&lt;/div&gt;&lt;!-- Navigation Bar --&gt;&lt;div class=&quot;navbar&quot;&gt;  &lt;a href=&quot;#&quot;&gt;Làng Công nghệ&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;Công nghệ&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;Khoa học&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;Cuộc sống&lt;/a&gt;&lt;/div&gt;&lt;!-- Nội dung --&gt;&lt;div class=&quot;row&quot;&gt;  &lt;div class=&quot;side&quot;&gt;    &lt;h2&gt;Giới thiệu&lt;/h2&gt;    &lt;div class=&quot;fakeimg&quot; style=&quot;height:200px;&quot;&gt;Ảnh&lt;/div&gt;    &lt;p&gt;Quantrimang.com là mạng xã hội về khoa học công nghệ.&lt;/p&gt;    &lt;h3&gt;Nổi bật&lt;/h3&gt;      &lt;div class=&quot;fakeimg&quot; style=&quot;height:60px;&quot;&gt;Ảnh&lt;/div&gt;&lt;br&gt;      &lt;div class=&quot;fakeimg&quot; style=&quot;height:60px;&quot;&gt;Ảnh&lt;/div&gt;&lt;br&gt;      &lt;div class=&quot;fakeimg&quot; style=&quot;height:60px;&quot;&gt;Ảnh&lt;/div&gt;    &lt;h3&gt;Follow Me&lt;/h3&gt;    &lt;p&gt;Facebook&lt;/p&gt;    &lt;p&gt;YouTube&lt;/p&gt;  &lt;/div&gt;  &lt;div class=&quot;main&quot;&gt;    &lt;h2&gt;Form - Biểu mẫu trong CSS&lt;/h2&gt;    &lt;h5&gt;Quách Tỉnh, 14/02/2019&lt;/h5&gt;    &lt;div class=&quot;fakeimg&quot; style=&quot;height:200px;&quot;&gt;Ảnh&lt;/div&gt;    &lt;p&gt;Form là một phần không thể thiếu trong bất kì loại website nào.&lt;/p&gt;    &lt;p&gt;Ở bài viết này, Quantrimang.com sẽ hướng dẫn bạn cách xây dựng phần     giao diện hiển thị của một biểu mẫu cơ bản. Giao diện này có thể được làm     khá đẹp mắt với CSS&lt;/p&gt;    &lt;br&gt;    &lt;h2&gt;Attribute Selector trong CSS&lt;/h2&gt;    &lt;h5&gt;Quách Tỉnh, 14/02/2019&lt;/h5&gt;    &lt;div class=&quot;fakeimg&quot; style=&quot;height:200px;&quot;&gt;Ảnh&lt;/div&gt;    &lt;p&gt;Attribute selector là cách chọn các phần tử bạn muốn định kiểu trong     tài liệu HTML dựa vào thuộc tính của một hay nhiều thẻ HTML nào đó.&lt;/p&gt;    &lt;p&gt;Attribute selector có thể chọn được các đối tượng mà không cần phải     khai báo thêm các Class hoặc ID vào trong thẻ HTML và vẫn có thể hướng     được đến các thành phần đó, giúp code gọn gàng hơn và mạch lạc hơn.&lt;/p&gt;  &lt;/div&gt;&lt;/div&gt;&lt;!-- Footer --&gt;&lt;div class=&quot;footer&quot;&gt;  &lt;h4&gt;Giấy phép số 362/GP-BTTTT. Bộ TT&amp;TT cấp ngày 30/06/2016.&lt;/h4&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

<div style="text-align: justify;">&nbsp;</div>
		</div>
				<div id="author">
						<p>
				<strong>Nguồn tin:</strong>
				Quantrimang.com:
			</p>
		</div>
	</div>
	<div id="footer" class="clearfix">
		<div id="url">
			<strong>URL của bản tin này: </strong><a href="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/su-dung-bo-cuc-trang-flexbox-trong-css-10231.html" title="Sử dụng bố cục trang Flexbox trong CSS">https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/su-dung-bo-cuc-trang-flexbox-trong-css-10231.html</a>

		</div>
		<div class="clear"></div>
		<div class="copyright">
			&copy; .&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.
		</div>
		<div id="contact">
			<a href="mailto:admin@nguoicodonvn2008.info">admin@nguoicodonvn2008.info</a>
		</div>
	</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng Site, <a onclick="timeoutsesscancel();" href="https://nguoicodonvn2008.info/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
		</script>
		<div class="car-top">
  <span><img src="https://nguoicodonvn2008.info/themes/default/images/car.png" alt=""></span>
</div>
<script src="https://nguoicodonvn2008.info/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="news",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=-4,nv_my_abbr="EDT",nv_cookie_prefix="nv4c_e856T",nv_check_pass_mstime=1738000,nv_area_admin=0,nv_safemode=0,theme_responsive=0,nv_recaptcha_ver=2,nv_recaptcha_sitekey="",nv_recaptcha_type="image",XSSsanitize=1;</script>
<script src="https://nguoicodonvn2008.info/assets/js/language/vi.js"></script>
<script src="https://nguoicodonvn2008.info/assets/js/DOMPurify/purify3.js"></script>
<script src="https://nguoicodonvn2008.info/assets/js/global.js"></script>
<script src="https://nguoicodonvn2008.info/assets/js/site.js"></script>
<script src="https://nguoicodonvn2008.info/themes/default/js/news.js"></script>
<script src="https://nguoicodonvn2008.info/themes/default/js/main.js"></script>
<script src="https://nguoicodonvn2008.info/themes/default/js/custom.js"></script>
<script type="application/ld+json">
        {
            "@context": "https://schema.org",
            "@type": "Organization",
            "url": "https://nguoicodonvn2008.info",
            "logo": "https://nguoicodonvn2008.info/uploads/angel.gif"
        }
        </script>
<script src="https://nguoicodonvn2008.info/themes/default/js/bootstrap.min.js"></script>
<script type="text/javascript">
var $scrolltop = $('.car-top');
$scrolltop.on('click', function () {
    $('html,body').animate({
        scrollTop: 0
    }, 800);
    $(this).addClass("car-run");
    setTimeout(function(){ $scrolltop.removeClass('car-run');}, 1000);
    return false;
});
$(window).on('scroll', function ()
{ 
    if($(window).scrollTop() >= 200)
    {
        $scrolltop.addClass("show");
        $scrolltop.addClass("car-down");
    }
    else
    {
       $scrolltop.removeClass("show");
       setTimeout(function(){ $scrolltop.removeClass('car-down');}, 300);
    }
});
</script>
</body>
</html>