<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>YOUPLAN &#187; CSS</title>
	<atom:link href="http://y-plan.jp/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://y-plan.jp</link>
	<description>bestmachi</description>
	<lastBuildDate>Tue, 10 Mar 2026 06:01:47 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.35</generator>
	<item>
		<title>レスポンシブに最適な フレキシブルレイアウトの プロパティ解説</title>
		<link>http://y-plan.jp/1023</link>
		<comments>http://y-plan.jp/1023#comments</comments>
		<pubDate>Wed, 25 Nov 2015 01:00:02 +0000</pubDate>
		<dc:creator><![CDATA[youplan]]></dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[レスポンシブ]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://y-plan.jp/?p=1023</guid>
		<description><![CDATA[スマートフォンやタブレットでインターネットを閲覧する時代になり、マルチデバイスに対応した可変レイアウト「レスポンシブデザイン」が求められる機会がたいへん多くなりました。 レスポンシブデザインのページを実装する際に、一役買 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>スマートフォンやタブレットでインターネットを閲覧する時代になり、マルチデバイスに対応した可変レイアウト「<strong>レスポンシブデザイン</strong>」が求められる機会がたいへん多くなりました。<br />
レスポンシブデザインのページを実装する際に、一役買ってくれるのが<strong>フレキシブルレイアウト</strong>です。<br />
フレキシブルレイアウトを利用すれば、ブロック要素をグリッド状に横並びに配置させたり、CSSで順番の並び替えを行ったりすることができます。</p>
<p>今回は、<strong>フレキシブルレイアウト</strong>の実装・各プロパティの解説していきます。</p>
<hr />
<h1>はじめに</h1>
<p>&nbsp;</p>
<div class="u-garter--in__pl">
<pre class="crayon-plain-tag">&lt;ul class="flex"&gt;
	&lt;li&gt;item1&lt;/li&gt;
	&lt;li&gt;item2&lt;/li&gt;
	&lt;li&gt;item3&lt;/li&gt;
&lt;/ul&gt;</pre>
</div>
<h2>display:</h2>
<p>displayプロパティに「flex」または「inline-flex」を指定すると、指定要素と子要素でフレキシブルレイアウトのプロパティが使用できるようになります。</p>
<div class="u-garter--in__pl">
<h6>flex</h6>
<p>子要素がブロックレベルのフレキシブルレイアウトを指定します。</p><pre class="crayon-plain-tag">.flex {
	display: flex;
}</pre><p></p>
<hr />
<h6>inline-flex</h6>
<p>子要素がインラインレベルのフレキシブルレイアウトを指定します。</p><pre class="crayon-plain-tag">.flex {
	display: inline-flex;
}</pre><p></p>
<hr />
</div>
<h1>整列順序の設定</h1>
<h2>flex-direction:</h2>
<p>子要素の配置方向を設定するプロパティで、横並びか縦並びかを指定できます。</p>
<div class="u-garter--in__pl">
<h6>row</h6>
<p>子要素を水平に、左から右へ正方向に並べます。<br />
<img class="alignnone size-full wp-image-1072" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0101.png" alt="flex0101" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-direction: row;
}</pre><p></p>
<hr />
<h6>row-reverse</h6>
<p>子要素を水平に、右から左へ逆方向に並べます。<br />
<img class="alignnone size-full wp-image-1085" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0102.png" alt="flex0102" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-direction: row-reverse;
}</pre><p></p>
<hr />
<h6>column</h6>
<p>子要素を垂直に、上から下に並べます。<br />
<img class="alignnone size-full wp-image-1087" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0103.png" alt="flex0103" width="900" height="282" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-direction: column;
}</pre><p></p>
<hr />
<h6>column-reverse</h6>
<p>子要素を垂直に、下から上へ逆方向に並べます。<br />
<img class="alignnone size-full wp-image-1088" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0104.png" alt="flex0104" width="900" height="282" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-direction: column-reverse;
}</pre><p></p>
<hr />
</div>
<h2>flex-wrap:</h2>
<p>子要素の折り返し方法を指定します。</p>
<div class="u-garter--in__pl">
<h6>nowrap</h6>
<p>flex-wrapプロパティの初期値で、子要素の折り返さずに並べます。<br />
<img class="alignnone size-full wp-image-1092" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0201.png" alt="flex0201" width="900" height="160" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-wrap: nowrap;
}</pre><p></p>
<hr />
<h6>wrap</h6>
<p>子要素を折り返します。<br />
<img class="alignnone size-full wp-image-1093" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0202.png" alt="flex0202" width="900" height="221" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-wrap: wrap;
}</pre><p></p>
<hr />
<h6>wrap-reverse</h6>
<p>子要素を上に折り返します。<br />
<img class="alignnone size-full wp-image-1094" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0203.png" alt="flex0203" width="900" height="221" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-wrap: wrap-reverse;
}</pre><p></p>
<hr />
</div>
<h2>flex-flow:</h2>
<p>flex-flowプロパティを利用して、flex-directionプロパティとflex-wrapプロパティを同時に指定できます。</p><pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-flow: row-reverse wrap-reverse;
}</pre><p></p>
<hr />
<h1>並び替えの設定</h1>
<h2>order:</h2>
<p>子要素に設定することで、順番を並び替えることができます。<br />
初期値は「0」が設定されており、「-1」を指定した要素が先頭に、「1」を指定した要素が末尾に並び替わります。</p>
<div class="u-garter--in__pl"><img class="alignnone size-full wp-image-1096" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0301.png" alt="flex0301" width="900" height="180" /><br />
<pre class="crayon-plain-tag">.flex {
	display: flex;
	}
	.flex li {
		order: 0;
	}</pre></p>
<hr />
<p><img class="alignnone size-full wp-image-1097" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0302.png" alt="flex0302" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	}
	.flex li {
		order: 0;
	}
	.flex li:nth-of-type(3) {
		order: 1;
	}</pre><p></p>
<hr />
<p><img class="alignnone size-full wp-image-1098" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0303.png" alt="flex0303" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	}
	.flex li {
		order: 0;
	}
	.flex li:nth-of-type(3) {
		order: -1;
	}</pre><p>
</div>
<hr />
<h1>サイズの設定</h1>
<h2>flex-grow:</h2>
<p>子要素に設定することで伸縮率を指定でき、子要素が親要素を埋め尽くすように自動でwidthが調整されます。<br />
全ての子要素に「1」を指定した場合、それぞれが均等のサイズに、<br />
そのうち1要素だけ「2」を指定した場合、その要素が「1」の要素の2倍の伸び幅でサイズ調整されます。</p>
<div class="u-garter--in__pl"><img class="alignnone size-full wp-image-1100" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0401.png" alt="flex0401" width="900" height="180" /><br />
<pre class="crayon-plain-tag">.flex {
	display: flex;
	}
	.flex li {
		flex-grow: 1;
	}</pre><br />
<img class="alignnone size-full wp-image-1101" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0402.png" alt="flex0402" width="900" height="180" /><br />
<pre class="crayon-plain-tag">.flex {
	display: flex;
	}
	.flex li {
		flex-grow: 1;
	}
	.flex li:nth-of-type(3) {
		flex-grow: 2;
	}</pre>
</div>
<hr />
<h2>flex-shrink:</h2>
<p>flex-shrinkプロパティは、flex-wrapプロパティで「nowrap」を指定時に、子要素が親要素をはみ出している場合に利用できます。<br />
全ての子要素に「1」を指定した場合、超過分を各要素から均等に縮小します。<br />
「2」を指定した要素は「1」を指定した要素の2倍縮小します。</p>
<div class="u-garter--in__pl"><img class="alignnone size-full wp-image-1103" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0403.png" alt="flex0403" width="900" height="180" /><br />
<pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-wrap: nowrap;
	}
	.flex li {
		flex-shrink: 1;
	}
	.flex li:nth-of-type(3) {
		flex-shrink: 2;
	}</pre>
</div>
<hr />
<h2>flex-basis:</h2>
<p>widthやheightのように値を指定できます。<br />
横並びのレイアウトの場合はwidthを、縦並びのレイアウトの場合はheightが指定されます。</p>
<div class="u-garter--in__pl">
<pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-wrap: nowrap;
	}
	.flex li {
		flex-basis: 300px;
	}</pre>
</div>
<hr />
<h2>flex:</h2>
<p>flexプロパティを利用して、flex-growプロパティ・flex-shrinkプロパティ・flex-basisプロパティを同時に指定できます。</p>
<div class="u-garter--in__pl">
<pre class="crayon-plain-tag">.flex {
	display: flex;
	flex-wrap: nowrap;
	}
	.flex li {
		flex: 1 1 300px;
	}</pre></p>
<hr />
<h1>整列の設定</h1>
<h2>justify-content:</h2>
<p>子要素の整列規則を設定します。</p>
<div class="u-garter--in__pl">
<h6>flex-start</h6>
<p>子要素を親要素の先頭から詰めるように整列させます。<br />
横並びのレイアウトの場合は「float:left」をのように左側に詰められ、余白が出る場合は右側に置かれます。<br />
<img class="alignnone size-full wp-image-1106" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0501.png" alt="flex0501" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	justify-content: flex-start;
}</pre><p></p>
<hr />
<h6>flex-end</h6>
<p>「flex-start」とは反対に、末尾から詰めるように整列させます。<br />
<img class="alignnone size-full wp-image-1107" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0502.png" alt="flex0502" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	justify-content: flex-end;
}</pre><p></p>
<hr />
<h6>center</h6>
<p>子要素が中央に詰められ配置されます。<br />
<img class="alignnone size-full wp-image-1108" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0503.png" alt="flex0503" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	justify-content: center;
}</pre><p></p>
<hr />
<h6>space-between</h6>
<p>それぞれの子要素が均等な間隔で余白を開けて整列します。<br />
<img class="alignnone size-full wp-image-1109" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0504.png" alt="flex0504" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	justify-content: space-between;
}</pre><p></p>
<hr />
<h6>space-around</h6>
<p>それぞれの子要素が両端に均等な余白を持って整列します。<br />
<img class="alignnone size-full wp-image-1110" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0505.png" alt="flex0505" width="900" height="180" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	justify-content: space-around;
}</pre><p></p>
<hr />
</div>
<h2>align-items:</h2>
<p>子要素の列の整列規則を設定します。</p>
<div class="u-garter--in__pl">
<h6>flex-start</h6>
<p>子要素の天辺を揃えて配置します。<br />
<img class="alignnone size-full wp-image-1111" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0601.png" alt="flex0601" width="900" height="260" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-items: flex-start;
}</pre><p></p>
<hr />
<h6>flex-end</h6>
<p>子要素の底辺を揃えて配置します。<br />
<img class="alignnone size-full wp-image-1112" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0602.png" alt="flex0602" width="900" height="260" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-items: flex-end;
}</pre><p></p>
<hr />
<h6>center</h6>
<p>子要素を中央揃えで配置します。<br />
<img class="alignnone size-full wp-image-1113" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0603.png" alt="flex0603" width="900" height="260" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-items: center;
}</pre><p></p>
<hr />
<h6>baseline</h6>
<p>ベースラインが一直線になるように配置されます。<br />
<img class="alignnone size-full wp-image-1114" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0604.png" alt="flex0604" width="900" height="260" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-items: baseline;
}</pre><p></p>
<hr />
<h6>stretch</h6>
<p>高さの指定がない子要素を最大サイズまで広げて配置します。<br />
<img class="alignnone size-full wp-image-1115" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0605.png" alt="flex0605" width="900" height="260" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-items: stretch;
}</pre><p></p>
<hr />
</div>
<h2>align-self:</h2>
<p>align-itemsプロパティが親要素で指定するのに対し、align-selfプロパティは子要素で指定できます。</p>
<hr />
<h2>align-content:</h2>
<p>子要素が列を折り返し複数行になっている場合の、列の整列規則を設定します。</p>
<div class="u-garter--in__pl">
<h6>flex-start</h6>
<p>子要素の列を親要素の天辺へ詰めて整列します。<br />
<img class="alignnone size-full wp-image-1116" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0701.png" alt="flex0701" width="900" height="330" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-content: flex-start;
}</pre><p></p>
<hr />
<h6>flex-end</h6>
<p>子要素の列を親要素の底辺へ詰めて整列します。<br />
<img class="alignnone size-full wp-image-1117" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0702.png" alt="flex0702" width="900" height="330" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-content: flex-end;
}</pre><p></p>
<hr />
<h6>center</h6>
<p>子要素の列が中央に詰められ配置されます。<br />
<img class="alignnone size-full wp-image-1118" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0703.png" alt="flex0703" width="900" height="330" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-content: center;
}</pre><p></p>
<hr />
<h6>space-between</h6>
<p>それぞれの子要素の列が均等な間隔で余白を開けて整列します。<br />
<img class="alignnone size-full wp-image-1119" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0704.png" alt="flex0704" width="900" height="330" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-content: space-between;
}</pre><p></p>
<hr />
<h6>space-around</h6>
<p>それぞれの子要素の列が両端に均等な余白を持って整列します。<br />
<img class="alignnone size-full wp-image-1120" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0705.png" alt="flex0705" width="900" height="330" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-content: space-around;
}</pre><p></p>
<hr />
<h6>stretch</h6>
<p>列に余白が出ないよう、子要素を引き伸ばし整列します。<br />
<img class="alignnone size-full wp-image-1121" src="http://y-plan.jp/wp/wp-content/uploads/2015/11/flex0706.png" alt="flex0706" width="900" height="330" /></p><pre class="crayon-plain-tag">.flex {
	display: flex;
	align-content: stretch;
}</pre><p>
</div>
<hr />
<h3>おわり</h3>
<p>コピペでご利用下さい。</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://y-plan.jp/1023/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
