<?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>Web制作 ウェブマジック &#187; CSSレイアウト</title>
	<atom:link href="http://www.hp-webmagic.com/wordpress/archives/tag/tag-csslayout/feed" rel="self" type="application/rss+xml" />
	<link>http://www.hp-webmagic.com/wordpress</link>
	<description>高品質なのに低価格 Web標準hp制作・CMS・ネットショップ</description>
	<lastBuildDate>Fri, 10 Feb 2012 03:27:49 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>clearfix：floatの解除</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/252</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/252#comments</comments>
		<pubDate>Tue, 28 Oct 2008 03:26:47 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[CSSプロパティ一覧]]></category>
		<category><![CDATA[CSSレイアウトサンプル]]></category>
		<category><![CDATA[CSSレイアウト]]></category>
		<category><![CDATA[ボックス指定]]></category>
		<category><![CDATA[背景指定]]></category>
		<category><![CDATA[配置指定]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=252</guid>
		<description><![CDATA[親ボックス内でfloatを解除する子ボックス[#footer{clear:both;}など]を設けない場合のfloat解除方法。 親ボックス内でfloatを解除しなかった場合、背景画像が表示されない、或いは親ボックスの下 [...]]]></description>
			<content:encoded><![CDATA[<p>親ボックス内でfloatを解除する子ボックス[#footer{clear:both;}など]を設けない場合のfloat解除方法。</p>
<p>親ボックス内でfloatを解除しなかった場合、背景画像が表示されない、或いは親ボックスの下まで表示されない場合などに有効だが、基本的には親ボックス内でfloatを解除した方がbetter。</p>
<pre>&lt;div id=&quot;box&quot;&gt;
&lt;div id=&quot;box-a&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;box-b&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
---- CSS ----
#box { width: 700px; margin: 0 auto; background: #******; }
#box-a { width: 500px; float: left; }
#box-b { width: 200px; float: right; }</pre>
<pre>&lt;div id=&quot;box&quot; class=&quot;clearfix&quot;&gt;
&lt;div id=&quot;box-a&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;box-b&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
---- CSS ----
#box { width: 700px; margin: 0 auto; background: #******; }

.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}

 .clearfix { display: inline-block; } /* Hides from IE-mac \*/
* html .clearfix { height: 1%; }
 .clearfix { display: block; } /* End hide from IE-mac */

#box-a { width: 500px; float: left; }
#box-b { width: 200px; float: right; }</pre>
<p>参考：<a href="http://www.positioniseverything.net/easyclearing.html">Clearing a float container without source markup</a></p>
<p>和訳：<a href="http://www.kuroduction.com/doc/translation/position_is_everything/easyclearing.html">構造のマークアップなしでフロートをクリアする方法</a></p>
<p>とても参考になる記事：<a href="http://norisfactory.com/stylesheetlab/000038.php">clearfixの決定版を作る －モダンブラウザ編－</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/252/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSSレイアウト-余白指定：padding</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/225</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/225#comments</comments>
		<pubDate>Wed, 20 Aug 2008 04:51:08 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[CSSレイアウトサンプル]]></category>
		<category><![CDATA[CSSレイアウト]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=225</guid>
		<description><![CDATA[余白（padding）の指定ついて解説します。CSS:floatレイアウトの基本&#160;で使用したサンプルレイアウトを例にします。余白の指定はレイアウトに影響を及ぼすので注意が必要です。特にウェブ標準に準拠したホーム [...]]]></description>
			<content:encoded><![CDATA[<p>余白（padding）の指定ついて解説します。<a href="http://www.hp-webmagic.com/wordpress/archives/214" title="CSS:floatレイアウトの基本">CSS:floatレイアウトの基本</a>&nbsp;で使用したサンプルレイアウトを例にします。余白の指定はレイアウトに影響を及ぼすので注意が必要です。特にウェブ標準に準拠したホームページ作成ではpaddingの指定は重要になります。基本をしっかり覚えましょう。以下は、ウェブ標準に準拠した場合の解説となります。</p>
<pre><span>(x)HTML</span>

&lt;div id=&quot;wrapper&quot;&gt;
&lt;div id=&quot;header&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;content&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;sidebar&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;***データ***&lt;/div&gt;
&lt;/div&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>css</span>

#wrapper{ width: 800px; }

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

#footer{ clear: both; }</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>padding指定の注意事項</h3>
<p><strong>標準準拠モードでは&nbsp;width&nbsp;及び&nbsp;height&nbsp;に&nbsp;padding&nbsp;を含みません。</strong></p>
<p><strong>後方互換モードは&nbsp;width&nbsp;及び&nbsp;height&nbsp;に&nbsp;padding&nbsp;を含みます。</strong></p>
<p>詳細：<a href="http://www.hp-webmagic.com/wordpress/archives/181" title="CSSレイアウト崩れの原因について">CSSレイアウト崩れの原因について</a></p>
<h4>#wrapper内に余白を設ける</h4>
<p>全体の幅は800pxで固定する事として解説します。</p>
<p>#wrapper内の左右に10pxの余白とる場合</p>
<pre>#wrapper{
  <span>width: 780px;
  padding: 0 10px;</span>
}

#content{
    <span>width: 580px;</span>
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
あるいは

#wrapper{
  <span>width: 780px;
  padding: 0 10px;</span>
}

#content{
    width: 600px;
    float: right;
}

#sidebar{
    <span>width: 180px;</span>
    float: left;
}

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
あるいは

#wrapper{
  <span>width: 780px;
  padding: 0 10px;</span>
}

#content{
    <span>width: 590px;</span>
    float: right;
}

#sidebar{
    <span>width: 190px;</span>
    float: left;
}</pre>
<p>今回は、全体の幅は800pxで固定する事としました。よって、左右にpaddingを10pxとるので#wrapperの幅は左右のpadding分を差し引いて780pxとしなければいけません。<strong>（標準準拠モードでは&nbsp;width&nbsp;及び&nbsp;height&nbsp;に&nbsp;padding&nbsp;を含みません。）</strong></p>
<p>後は、#wrapper内の#contentと#sidebarの幅を780pxに合うように変更すれば上手く段組み出来ます。</p>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h4>#header内に余白を設ける</h4>
<p>#header内の上下に20px、左右に10pxの余白とる場合</p>
<pre>#wrapper{ width: 800px; }

#header{
  <span>height: 80px;
  padding: 20px 10px;</span>
}</pre>
<p>#headerの幅は#wrapperのwidthが基準となるので特に指定は要りませんが、高さは上下に設けた余白分差し引かなければいけません。<strong>（標準準拠モードでは&nbsp;width&nbsp;及び&nbsp;height&nbsp;に&nbsp;padding&nbsp;を含みません。）</strong></p>
<p>#headerに背景画像を指定する際など重要です。</p>
<p>もうひとつの方法として、#header内に#header-innerを設ける方法があります。<abbr title="MovableType">MT</abbr>や<abbr title="Wordpress">WP</abbr>などのブログソフトウェアでよくある構造です。</p>
<pre><span>(x)HTML</span>

&lt;div id=&quot;wrapper&quot;&gt;
&lt;div id=&quot;header&quot;&gt;
<span>&lt;div id=&quot;header-inner&quot;&gt;***データ***&lt;/div&gt;</span>
&lt;/div&gt;
&lt;div id=&quot;content&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;sidebar&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;***データ***&lt;/div&gt;
&lt;/div&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>css</span>

#wrapper{ width: 800px; }

#header{ height: 120px; }

<span>#header-inner{ margin: 20px 10px; }</span></pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h4>#contentと#sidebar内に余白を設ける</h4>
<p>全体の幅は800pxで固定する事として解説します。</p>
<p>#contentと#sidebar共に、左右20pxのpaddingを設ける場合。</p>
<pre>#wrapper{ width: 800px; }

#content{
    <span>width: 560px;</span>
    float: right;
    <span>padding: 0 20px;</span>
}

#sidebar{
    <span>width: 160px;</span>
    float: left;
    <span>padding: 0 20px;</span>
}</pre>
<p>#contentと#sidebar共に、左右に20pxのpaddingを設けたので、それぞれのwidthから40px分差し引かなければいけません。<strong>（標準準拠モードでは&nbsp;width&nbsp;及び&nbsp;height&nbsp;に&nbsp;padding&nbsp;を含みません。）</strong></p>
<p>参考までに、もしwidth指定を変更しなかったら、標準準拠モードでは#contentの幅は640px、#sidebarの幅は240px、合わせて880pxと計算されます。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/225/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSSレイアウト-余白指定：margin</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/222</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/222#comments</comments>
		<pubDate>Wed, 20 Aug 2008 03:50:19 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[CSSレイアウトサンプル]]></category>
		<category><![CDATA[CSSレイアウト]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=222</guid>
		<description><![CDATA[余白（margin）の指定ついて解説します。CSS:floatレイアウトの基本&#160;で使用したサンプルレイアウトを例にします。余白の指定はレイアウトに影響を及ぼすので注意が必要です。基本をしっかり覚えましょう。 ( [...]]]></description>
			<content:encoded><![CDATA[<p>余白（margin）の指定ついて解説します。<a href="http://www.hp-webmagic.com/wordpress/archives/214" title="CSS:floatレイアウトの基本">CSS:floatレイアウトの基本</a>&nbsp;で使用したサンプルレイアウトを例にします。余白の指定はレイアウトに影響を及ぼすので注意が必要です。基本をしっかり覚えましょう。</p>
<pre><span>(x)HTML</span>

&lt;div id=&quot;wrapper&quot;&gt;
&lt;div id=&quot;header&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;content&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;sidebar&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;***データ***&lt;/div&gt;
&lt;/div&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>css</span>

#wrapper{ width: 800px; }

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

#footer{ clear: both; }</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>#wrapper内に余白を設ける</h3>
<p>全体の幅は800pxで固定する事として解説します。</p>
<p>#wrapperと#content及び#sidebarとの間に余白を設けたい時など、基本的にmarginで余白を設定するのは難しいと考えて下さい。<abbr title="Internet Explorer 6">IE6</abbr>の場合、floatプロパティで指定した方向と同方向にmarginをとると、marginで指定した長さの2倍余白をとるバグを抱えています。よって、簡単に余白を設ける場合は次頁の余白指定：paddingを参照して下さい。</p>
<p>参考までにmargin指定で余白をとる場合</p>
<p>1：#wrapperの中にもうひとつボックス（#wrapper-inner）を設ける</p>
<pre><span>(x)HTML</span>

&lt;div id=&quot;wrapper&quot;&gt;
<span>&lt;div id=&quot;wrapper-inner&quot;&gt;</span>
&lt;div id=&quot;header&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;content&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;sidebar&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;***データ***&lt;/div&gt;
<span>&lt;/div&gt;</span>
&lt;/div&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>css</span>

#wrapper{ width: 800px; }

/* 左右に10pxとったので、実際の入力可能範囲は 780pxである事に注意  */
<span>#wrapper-inner{ margin: 0 10px; }</span>

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
}

/* 780pxに納まるように指定  */
#sidebar{
    <span>width: 180px;</span>
    float: left;
}

#footer{ clear: both; }</pre>
<p>2：#contentと#sidebarの中にもうひとつボックス（#content-innerと#sidebar-inner）を設ける</p>
<pre style="height:500px;"><span>(x)HTML</span>

&lt;div id=&quot;wrapper&quot;&gt;
&lt;div id=&quot;header&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;content&quot;&gt;
<span>&lt;div id=&quot;content-inner&quot;&gt;***データ***&lt;/div&gt;</span>
&lt;/div&gt;
&lt;div id=&quot;sidebar&quot;&gt;
<span>&lt;div id=&quot;sidebar-inner&quot;&gt;***データ***&lt;/div&gt;</span>
&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;***データ***&lt;/div&gt;
&lt;/div&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>css</span>

#wrapper{ width: 800px; }

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
}

/* 右に10pxとったので、実際の入力可能範囲は 590pxである事に注意  */
<span>#content-inner{ margin-right: 10px; }</span>

#sidebar{
    width: 200px;
    float: left;
}

/* 左に10pxとったので、実際の入力可能範囲は 190pxである事に注意  */
<span>#sidebar-inner{ margin-left: 10px; }</span>

#footer{ clear: both; }</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>#header下に余白を設ける</h3>
<pre>#header{
  height: 120px;
  <span>margin-bottom: 50px;</span>
}</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>#contentと#sidebarの間に余白を設ける</h3>
<p>全体の幅は800pxで固定する事として解説します。</p>
<p>最も簡単な方法</p>
<p>#contentと#sidebarのwidth指定で800px以下になるように指定します。#contentはfloat:right;で右側に、#sidebarはfloat:left;で左側にいっぱい寄るので設けたい余白分、どちらかのwidthを小さくするか、あるいは両方小さくするかで自然な余白を設ける事ができます。</p>
<p>#contentと#sidebarの間に40px余白を設ける場合</p>
<pre>#contentを小さくする

#wrapper{ width: 800px; }

#content{
    <span>width: 560px;</span>
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#sidebarを小さくする

#wrapper{ width: 800px; }

#content{
    width: 600px;
    float: right;
}

#sidebar{
    <span>width: 160px;</span>
    float: left;
}

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
両方小さくする

#wrapper{ width: 800px; }

#content{
    <span>width: 580px;</span>
    float: right;
}

#sidebar{
    <span>width: 180px;</span>
    float: left;
}</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>#footer上に余白を設ける</h3>
<p><span>clearプロパティが指定してある要素に、上方向のmarginを指定しても指定は反映されません。<span></span></span></p>
<p>#footer上に余白を設ける時は、#contentと#sidebarの方に下方向のmargin指定をします。</p>
<p>#footer上に50pxの余白を設ける場合</p>
<pre>#wrapper{ width: 800px; }

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
    <span>margin-bottom: 50px;</span>
}

#sidebar{
    width: 200px;
    float: left;
    <span>margin-bottom: 50px;</span>
}

#footer{ clear: both; }

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
あるいは

#wrapper{ width: 800px; }

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

<span>#content,
#sidebar{ margin-bottom: 50px; }</span>

#footer{ clear: both; }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/222/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSSレイアウト-横幅を変更するには：#wrapper</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/219</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/219#comments</comments>
		<pubDate>Wed, 20 Aug 2008 01:53:52 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[CSSレイアウトサンプル]]></category>
		<category><![CDATA[CSSレイアウト]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=219</guid>
		<description><![CDATA[ホームページ全体の横幅の変更方法について解説します。前頁&#160;CSS:floatレイアウトの基本&#160;で使用したサンプルレイアウトを例にします。 (x)HTML &#60;div id=&#34;wrappe [...]]]></description>
			<content:encoded><![CDATA[<p>ホームページ全体の横幅の変更方法について解説します。前頁&nbsp;<a href="http://www.hp-webmagic.com/wordpress/archives/214" title="CSS:floatレイアウトの基本">CSS:floatレイアウトの基本</a>&nbsp;で使用したサンプルレイアウトを例にします。</p>
<pre><span>(x)HTML</span>

&lt;div id=&quot;wrapper&quot;&gt;
&lt;div id=&quot;header&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;content&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;sidebar&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;***データ***&lt;/div&gt;
&lt;/div&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>css</span>

#wrapper{ width: 800px; }

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

#footer{ clear: both; }</pre>
<p>ヘッダー部分（#header）、コンテンツ部分（#content）、サイドバー部分（#sidebar）、フッター部分（#footer）はすべて親ボックスの<span>#wrapper</span>の中に包括されています。よって、ホームページ全体の横幅を変更するにはcssの#wrapper部分のwidthを変更してやります。</p>
<p>この時、ヘッダー部分（#header）とフッター部分（#footer）は幅指定をしていないので、今回のようにホームページ全体の横幅を変更しても、レイアウトに及ぼす影響はありません。（今回は、最も簡単でシンプルな段組を採用しています。）#wrapperのwidthに合わせて伸縮します。</p>
<p>コンテンツ部分（#content）とサイドバー部分（#sidebar）はwidth指定と、float指定でそれぞれ左右に配置しているので、#wrapperのwidthに合わせて変更してやらなければなりません。</p>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>横幅計算の基本</h3>
<p>横幅を変更する際の簡単な四則計算について説明しておきます。</p>
<p>仮にサンプルの横幅を760pxとした場合サンプルホームページはどうなるでしょう。この場合は#sidebarが#contentの下へ落ちてしまいレイアウトが著しく崩れてしまいます。cssソースを見ても一目瞭然で、#contentのwidthが600px、#sidebarのwidthが200px、合計で800pxなので760px内に納まるわけがありません。</p>
<p>横幅変更の際だけでなく、ホームページを作成する際の横幅は、<span>基準となる要素（今回は#wrapper）の中にそれぞれの内包要素が納まるように指定しなければなりません。</span></p>
<p>今回は、各要素の余白（&nbsp;margin&nbsp;padding&nbsp;）やborder指定をしていませんが、これらの指定を加えていくと、初心者の場合、必ずと言っていいほどレイアウト崩れを起こします。その場合でも、基準となる要素内にそれぞれの要素が上手く納まるように計算するのが基本です。つまり、簡単な足算と引算が最も重要という事です。</p>
<p>関連：<a href="http://www.hp-webmagic.com/wordpress/archives/181" title="CSSレイアウト崩れの原因について">CSSレイアウト崩れの原因について</a></p>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h4>横幅を小さくするには</h4>
<p>横幅を小さくする（狭くする）指定について説明します。今回は#wrapperを760pxとして解説します。</p>
<p>基準要素の幅が760pxとなるので、#content、#sidebarのwidthを760px、もしくは760px以下に指定しなければなりません。考えるのは、#contentのwidthを小さくする、あるいは#sidebarのwidthを小さくして、#contentと#sidebarのwidthの合計が#wrapperのwidth:760px;と同等か、あるいは760px以下になるように計算する事です。以下は、横幅を小さくする（狭くする）際のcssサンプルの一例です。</p>
<pre><span>#contentの幅を変更のパターン</span>

#wrapper{ width: 760px; }

#header{ height: 120px; }

#content{
    <span>width: 560px;</span>
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

#footer{ clear: both; }

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>#sidebarの幅を変更のパターン</span>

#wrapper{ width: 760px; }

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
}

#sidebar{
    width: <span>160px;</span>
    float: left;
}

#footer{ clear: both; }

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>#content #sidebarの幅を変更のパターン</span>

#wrapper{ width: 760px; }

#header{ height: 120px; }

#content{
    width: <span>580px;</span>
    float: right;
}

#sidebar{
    width: <span>180px;</span>
    float: left;
}

#footer{ clear: both; }</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h4>横幅を大きくするには</h4>
<p>横幅を大きくする（広くする）指定について説明します。今回は#wrapperを860pxとして解説します。</p>
<p>基準要素の幅が860pxとなるので、サンプルの指定のままでは#contentと#sidebarの間に60pxの空白が生じてしまいます。（これは実際には、レイアウトを崩さない為の指定テクニックです。）よって#content、#sidebarのwidthを860px、もしくは860px以下になるように指定します。考えるのは、#contentのwidthを大きくする、あるいは#sidebarのwidthを大きくして、#contentと#sidebarのwidthの合計が#wrapperのwidth:860px;と同等か、あるいは860px以下になるように計算する事です。以下は、横幅を大きくする（広くする）際のcssサンプルの一例です。</p>
<pre><span>#contentの幅を変更のパターン</span>

#wrapper{ width: 860px; }

#header{ height: 120px; }

#content{
    <span>width: 660px;</span>
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

#footer{ clear: both; }

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>#sidebarの幅を変更のパターン</span>

#wrapper{ width: 860px; }

#header{ height: 120px; }

#content{
    width: 600px;
    float: right;
}

#sidebar{
    width: <span>260px;</span>
    float: left;
}

#footer{ clear: both; }

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>#content #sidebarの幅を変更のパターン</span>

#wrapper{ width: 860px; }

#header{ height: 120px; }

#content{
    width: <span>640px;</span>
    float: right;
}

#sidebar{
    width: <span>220px;</span>
    float: left;
}

#footer{ clear: both; }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/219/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS:floatレイアウトの基本</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/214</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/214#comments</comments>
		<pubDate>Tue, 19 Aug 2008 07:13:45 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[CSSレイアウトサンプル]]></category>
		<category><![CDATA[CSSレイアウト]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=214</guid>
		<description><![CDATA[CSS：floatレイアウト（段組）の基本解説です。CSS：floatプロパティを使ったホームページの作り方を、初心者用に解りやすく解説します。尚、CSSは外部CSSを利用したと仮定しています。以下はCSS：floatプ [...]]]></description>
			<content:encoded><![CDATA[<p>CSS：floatレイアウト（段組）の基本解説です。CSS：floatプロパティを使ったホームページの作り方を、初心者用に解りやすく解説します。尚、CSSは外部CSSを利用したと仮定しています。以下はCSS：floatプロパティを使った最も簡単な段組の基本部分をイメージ画像にしてみました。</p>
<p><img src="http://www.hp-webmagic.com/wordpress/wp-content/uploads/float-image1.gif" alt="css:floatレイアウトのイメージ" title="float-image" width="500" height="235" class="alignnone size-full wp-image-312" /></p>
<p>floatレイアウトの基本は、上記のように親ボックスの中で左右に配置させたい子ボックスをfloat指定により回り込ませ、最後に回り込みを解除するのが最も簡単な段組です。では、親ボックスと子ボックスを実際の作成例に沿って置き換えてみます。</p>
<p>まずそれぞれの要素（div要素）を用意します。</p>
<pre><span>(x)HTML</span>

&lt;div&gt;&lt;/div&gt; &lt;!-- 親ボックス -- &gt;
&lt;div&gt;&lt;/div&gt; &lt;!-- 子ボックス -- &gt;
&lt;div&gt;&lt;/div&gt; &lt;!-- 子ボックス -- &gt;
&lt;div&gt;&lt;/div&gt; &lt;!-- 子ボックス -- &gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
親ボックス内に子ボックスを配置するので
<span>&lt;div&gt;</span> &lt;!-- 親ボックス -- &gt;
&lt;div&gt;&lt;/div&gt; &lt;!-- 子ボックス -- &gt;
&lt;div&gt;&lt;/div&gt; &lt;!-- 子ボックス -- &gt;
&lt;div&gt;&lt;/div&gt; &lt;!-- 子ボックス -- &gt;
<span>&lt;/div&gt;</span> &lt;!-- 親ボックスの終わり -- &gt;</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>idセレクタ名をつける</h3>
<p>上記サンプル図のボックスに、それぞれ任意のセレクタ&quot;名をつけます。セレクタ名は一目でわかる言葉（単語など）を指定します。ここでは下記のように指定します。</p>
<ul>
<li>親ボックス(div)を&#160;wrapperとする。</li>
<li>ひとつ目の子ボックス(div)を&#160;contentとする。</li>
<li>ふたつ目の子ボックス(div)を&#160;sidebarとする。</li>
<li>最後の子ボックス(div)を&#160;footerとする。</li>
</ul>
<p>上記の条件で、サンプル図の解説分を読み替えてみます。</p>
<p>wrapper内でcontentとsidebarを左右に配置。<br />
wrapper内で回り込みを解除（footer）。という事になります。</p>
<pre><span>(x)HTML</span>

&lt;!-- wrapper内に各要素（ボックス）を配置 --&gt;
&lt;div id=&quot;wrapper&quot;&gt;
&lt;div id=&quot;content&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;sidebar&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;***データ***&lt;/div&gt;
&lt;/div&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>css</span>
#wrapper{ 各種指定 }
#content{ 各種指定 }
#sidebar{ 各種指定 }
#footer{ 各種指定 }</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>CSS指定/レイアウトを考える</h3>
<p>実際に各要素のCSS指定をしていきます。</p>
<p>まず最初に考える事は、全体の幅（width）をどうするかです。固定幅にするのか、可変幅（リキッドレイアウト）にするのか、コンテンツ部分の幅（width）、サイドバーの幅（width）、右サイドバータイプ、左サイドバータイプなどを考えます。ここでは以下の条件で指定していきます。</p>
<ul>
<li>全体の幅（#wrapper）を800pxの固定幅とする。</li>
<li>左サイドバータイプとする。</li>
<li>コンテンツ部分の幅（#content）を600pxとする。</li>
<li>サイドバー部分の幅（#sidebar）を200pxとする。</li>
</ul>
<pre><span>css</span>

#wrapper{ width: 800px; }

#content{
    width: 600px;
    float: right;  /* 右に配置 */
}

#sidebar{
    width: 200px;
    float: left;  /* 左に配置 */
}

#footer{ clear: both; }  /* float解除 */</pre>
<dl>
<dt>ワンポイント</dt>
<dd>
<p>右サイドバータイプにする場合、上記の#contentと#sidebarのfloat指定を逆にします。CSS指定で左右の変更が簡単に出来るのがCSSレイアウトのメリットです。</p>
<p>右サイドバータイプにする場合の別の方法として、単に#sidebarのfloat指定をleftにしても良いのですが、#contentと#sidebarのfloat指定は左右別々にした方が、レイアウト上でかなり融通がききます。</p>
</dd>
</dl>
<p>右サイドバーにする時のCSSソースサンプル</p>
<pre><span>css</span>

#content{
    width: 600px;
    float: left;  /* 左に配置 */
}

#sidebar{
    width: 200px;
    float: right;  /* 右に配置 */
}</pre>
<p class="page-top"><a href="#header" title="このページの先頭へ">Page Top</a></p>
<h3>ヘッダーを追加する</h3>
<p>ホームページらしく、ヘッダー部分を追加します。今回ヘッダー部分は#headerとします。指定は簡単で#wrapper内に#headerを挿入するだけです。</p>
<pre><span>(x)HTML</span>

&lt;div id=&quot;wrapper&quot;&gt;
<span>&lt;div id=&quot;header&quot;&gt;***データ***&lt;/div&gt;</span>
&lt;div id=&quot;content&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;sidebar&quot;&gt;***データ***&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;***データ***&lt;/div&gt;
&lt;/div&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<span>css</span>

#wrapper{ width: 800px; }

/*
高さだけ指定しています。
#headerの幅は指定しなくても#wrapperのwidth分広がります
*/
<span>#header{ height: 120px; }</span>

#content{
    width: 600px;
    float: right;
}

#sidebar{
    width: 200px;
    float: left;
}

#footer{ clear: both; }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/214/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>レイアウト崩れ：float指定</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/193</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/193#comments</comments>
		<pubDate>Tue, 12 Aug 2008 02:19:07 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[レイアウト崩れの原因]]></category>
		<category><![CDATA[CSSレイアウト]]></category>
		<category><![CDATA[レイアウト崩れ]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=193</guid>
		<description><![CDATA[CSS指定によるレイアウト崩れの原因についてのチェック項目です。（標準準拠モードで表示する事を想定しています） floatに関する指定について 以下はfloat指定の際の注意項目です。確認してみて下さい。 width指定 [...]]]></description>
			<content:encoded><![CDATA[<p>CSS指定によるレイアウト崩れの原因についてのチェック項目です。（標準準拠モードで表示する事を想定しています）</p>
<h3>floatに関する指定について</h3>
<p>以下はfloat指定の際の注意項目です。確認してみて下さい。</p>
<h4>width指定をしていない。</h4>
<p>すべてのブラウザで起こるわけではありませんが、Mac IE5ではfloat指定の際widthも指定しなければ回り込みが上手く反映されません。</p>
<p>widthを指定する事は、余白を設定する場合やリンク領域を要素全体に広げたい際にも重要になります。普段から記述する事をお勧めします</p>
<h4>floatを指定した同方向にmarginを指定している。</h4>
<pre>サンプル

#sample{
float: left;
width: 180px;
margin-left: 20px;
}</pre>
<p>IEではfloatと同方向にmarginを取ると、幅が2倍で表示されます。</p>
<h4>widthの計算。</h4>
<ul>
<li>全体の幅を超えていないか</li>
<li>余白分差し引いているか</li>
<li>border分差し引いているか</li>
</ul>
<p>以下のCSS指定サンプルではレイアウトは崩れます</p>
<pre>#wrapper{ <span>width: 700px;</span> }

#content{
    width: <span>500px;</span> /* この場合なら 489px */
    float: left;
    margin: 0 <span>10px</span> 0 0;
    <span>border-right: 1px solid #000;</span>
}

#sidebar{
    width: 200px;
    float: right;
}

#footer{ clear: both; }</pre>
<p>標準準拠モードと後方互換モードに関する部分です。詳細は<a href="http://www.hp-webmagic.com/wordpress/archives/181" title="CSSレイアウト崩れの原因について">CSSレイアウト崩れの原因について</a>で確認して下さい。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/193/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>レイアウト崩れ：文書型定義（DTD）</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/191</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/191#comments</comments>
		<pubDate>Tue, 12 Aug 2008 01:57:08 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[レイアウト崩れの原因]]></category>
		<category><![CDATA[CSSレイアウト]]></category>
		<category><![CDATA[DOCTYPE]]></category>
		<category><![CDATA[レイアウト崩れ]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=191</guid>
		<description><![CDATA[CSS指定によるレイアウト崩れの原因についてのチェック項目です。（標準準拠モードで表示） どの文書型定義（DTD）に従って記述しているかを明確にします。以下はDTDとレタリングモードの一覧です。 DOCTYPE宣言とブラ [...]]]></description>
			<content:encoded><![CDATA[<p>CSS指定によるレイアウト崩れの原因についてのチェック項目です。（標準準拠モードで表示）</p>
<p>どの文書型定義（DTD）に従って記述しているかを明確にします。以下はDTDとレタリングモードの一覧です。</p>
<table border="0" cellpadding="0" cellspacing="0" class="table-dtd" summary="DOCTYPE宣言とブラウザレタリングモード">
<caption>DOCTYPE宣言とブラウザレタリングモード表</caption>
<tr>
<td colspan="6" class="doctype">&lt;!DOCTYPE HTML PUBLIC &#8220;-//W3C//DTD HTML 4.01 Transitional//EN&#8221;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>互換モード</td>
<td>互換モード</td>
<td>互換モード</td>
<td>互換モード</td>
<td>互換モード</td>
<td>互換モード</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;!DOCTYPE HTML PUBLIC &#8220;-//W3C//DTD HTML 4.01 Transitional//EN&#8221;<br />
&#8220;http://www.w3.org/TR/html4/loose.dtd&#8221;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;!DOCTYPE HTML PUBLIC &#8220;-//W3C//DTD HTML 4.01 Strict //EN&#8221;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>互換モード</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;!DOCTYPE HTML PUBLIC &#8220;-//W3C//DTD HTML 4.01 Strict //EN&#8221;<br />
&#8220;http://www.w3.org/TR/html4/strict.dtd&#8221;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;<br />
&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;?xml version=&quot;1.0&quot; encoding=&quot;文字コード&quot;?&gt;<br />
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;<br />
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>互換モード</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;<br />
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;?xml version=&quot;1.0&quot; encoding=&quot;文字コード&quot;?&gt;<br />
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;<br />
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>互換モード</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.1//EN&#8221;<br />
&#8220;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&#8221;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
</tr>
<tr>
<td colspan="6" class="doctype">&lt;?xml version=&quot;1.0&quot; encoding=&quot;文字コード&quot;?&gt;<br />
&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.1//EN&#8221;<br />
&#8220;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&#8221;&gt;</td>
</tr>
<tr>
<td>IE7</td>
<td>IE6</td>
<td>Firefox</td>
<td>Opera</td>
<td>Safari</td>
<td>MacIE5</td>
</tr>
<tr>
<td>標準準拠</td>
<td>互換モード</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
<td>標準準拠</td>
</tr>
</table>
<h3>XML宣言について</h3>
<p>上記レタリングモード一覧にもあるように、IE6ではXMLを宣言すると強制的に互換モード表示になります。CSS側での対応も可能ですが、現状ではXMLを宣言しない方が（記述しない）望ましいです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/191/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>レイアウト崩れ：セレクタ名</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/189</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/189#comments</comments>
		<pubDate>Tue, 12 Aug 2008 01:38:19 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[レイアウト崩れの原因]]></category>
		<category><![CDATA[CSSレイアウト]]></category>
		<category><![CDATA[レイアウト崩れ]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=189</guid>
		<description><![CDATA[CSS指定によるレイアウト崩れの原因についてのチェック項目です。（標準準拠モードで表示） この項目はレイアウト崩れにはあまり関係がありませんが、この項目も(X)HTMLの見直しと同様に基本的な部分であり、CSSの指定が反 [...]]]></description>
			<content:encoded><![CDATA[<p>CSS指定によるレイアウト崩れの原因についてのチェック項目です。（標準準拠モードで表示）</p>
<p>この項目はレイアウト崩れにはあまり関係がありませんが、この項目も<a href="http://www.hp-webmagic.com/wordpress/archives/187" title="(X)HTMLの見直し">(X)HTMLの見直し</a>と同様に基本的な部分であり、CSSの指定が反映されない時などは、下記のパターンが大半です。</p>
<ul>
<li>id or classの記述ミス</li>
<li>セレクタ名の記述ミス</li>
</ul>
<h3>id or classの記述ミス</h3>
<p>例えば、(X)HTML側で&lt;div <span>id=&#8221;sample&#8221;</span>&gt;としているにも関わらずCSS側では<span>.sample</span>としている。</p>
<h3>セレクタ名の記述ミス</h3>
<p>例えば、(X)HTML側で&lt;div id=&#8221;<span>sidebar</span>&#8220;&gt;としているにも関わらずCSS側では<span>#left-sidebar</span>としている。</p>
<p>例えば、(X)HTML側で&lt;div id=&#8221;<span>left-sidebar</span>&#8220;&gt;としているにも関わらずCSS側では<span>#left_sidebar</span>としている。</p>
<p>初歩的なミスですが、実際この手の記述ミスは案外多いものです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/189/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>レイアウト崩れ：(X)HTMLの見直し</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/187</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/187#comments</comments>
		<pubDate>Tue, 12 Aug 2008 01:22:16 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[レイアウト崩れの原因]]></category>
		<category><![CDATA[CSSレイアウト]]></category>
		<category><![CDATA[レイアウト崩れ]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=187</guid>
		<description><![CDATA[CSS指定によるレイアウト崩れの原因についてのチェック項目です。（標準準拠モードで表示） CSSのプロパティ等についての知識が豊富でも、肝心な(X)HTMLの記述がおろそかでは何の意味もありません。ウェブ標準仕様に従うの [...]]]></description>
			<content:encoded><![CDATA[<p>CSS指定によるレイアウト崩れの原因についてのチェック項目です。（標準準拠モードで表示）</p>
<p>CSSのプロパティ等についての知識が豊富でも、肝心な(X)HTMLの記述がおろそかでは何の意味もありません。ウェブ標準仕様に従うのであれば、(X)HTMLの正確なマークアップと正しい使い方をしなければなりません。</p>
<p><span>CSSの指定を調べる前に、(X)HTMLの記述が正しく行われているかを確認しましょう。</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/187/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSSレイアウト崩れの原因について</title>
		<link>http://www.hp-webmagic.com/wordpress/archives/181</link>
		<comments>http://www.hp-webmagic.com/wordpress/archives/181#comments</comments>
		<pubDate>Mon, 11 Aug 2008 06:43:06 +0000</pubDate>
		<dc:creator>Web Magic</dc:creator>
				<category><![CDATA[レイアウト崩れの原因]]></category>
		<category><![CDATA[CSSレイアウト]]></category>
		<category><![CDATA[DOCTYPE]]></category>
		<category><![CDATA[レイアウト崩れ]]></category>

		<guid isPermaLink="false">http://www.hp-webmagic.com/?p=181</guid>
		<description><![CDATA[CSS指定によるレイアウト崩れの原因について、初心者の方々でも分かりやすく解説していきます。例えば、下記のような場合の対処です。 IEでは上手く表示しているのに、Firefoxで表示したらサイドバーが落ちていた。 IE6 [...]]]></description>
			<content:encoded><![CDATA[<p>CSS指定によるレイアウト崩れの原因について、初心者の方々でも分かりやすく解説していきます。例えば、下記のような場合の対処です。</p>
<ul>
<li>IEでは上手く表示しているのに、Firefoxで表示したらサイドバーが落ちていた。</li>
<li>IE6では上手く表示しているのに、IE7で表示したらサイドバーが落ちていた。</li>
<li>Macで表示したらレイアウトが崩れていた。</li>
</ul>
<p><span>CSS指定によるレイアウト崩れの原因については、さまざまな要因が考えられますが、基本は(X)HTMLのマークアップが正しく記述されているかを最初に確認しておきましょう。</span></p>
<p>以下のレイアウト崩れに関する解説は、CSSハックの解説ではありません。IE7の登場によりIE6で使用可能だったハックがIE７では無効となるように、ブラウザ側の対応も次第に改善方向に向かいます。ハックは取り敢えずの処置と考え、CSS指定の基本を理解しましょう。</p>
<h3>ボックスモデルの概念</h3>
<p>レイアウトの場合だけでなく、&lt;div&gt; &lt;h1&gt; &lt;img&gt;等の各要素にもCSS指定をしますが、これらの各要素はすべてボックスという概念を持っています。</p>
<p><img src="http://www.hp-webmagic.com/wordpress/wp-content/uploads/boxmodel2.jpg" alt="ボックスモデル" title="boxmodel" width="400" height="620" class="alignnone size-full wp-image-313" /></p>
<p>CSS指定でのレイアウト崩れの原因の多くは、上記サンプル図の <span>padding</span> と <span>border</span> によるところが大半です。</p>
<h3>標準準拠モードと後方互換モード</h3>
<p>標準準拠モードと後方互換モードのCSS解釈の違いについて解説します。</p>
<p><a href="http://www.hp-webmagic.com/wordpress/archives/124" title="表示モードについて">表示モードについて</a></p>
<p><strong>標準準拠モードは width 及び height  に padding 及び border を含みません。</strong></p>
<p><strong>後方互換モードは width 及び height  に padding 及び border を含みます。</strong></p>
<p>簡単なサンプルとして下記のような指定をした場合、</p>
<pre>div.sample{
    width: 400px;
    padding: 20px;
    border: 10px solid #000;
}</pre>
<p>後方互換モードは width 及び height  に padding 及び border を含むので幅は400pxです。</p>
<p>標準準拠モードは width 及び height  に padding 及び border を含まないので下記サンプルのようになります。</p>
<p><img src="http://www.hp-webmagic.com/wordpress/wp-content/uploads/boxmodelefbc921.jpg" alt="ボックスのCSS解釈について" title="boxmodelefbc921" width="460" height="470" class="alignnone size-full wp-image-314" /></p>
<p>上記のように、CSSで指定した width:400px; はcontent領域(データ領域)の幅を意味します。つまり、上記サンプル指定では、content領域(データ領域)が400px、paddingが左右で40px、borderが左右で20px、合計460pxがdiv.sampleの横幅になります。尚、今回、高さについては無視していますが基本は同様です。</p>
<p>標準準拠モードでwidth:400px;にする場合は下記のように指定します。</p>
<p><img src="http://www.hp-webmagic.com/wordpress/wp-content/uploads/boxmodelefbc931.jpg" alt="標準準拠モード指定サンプル" title="boxmodele" width="400" height="380" class="alignnone size-full wp-image-315" /></p>
<p>全体の幅を400pxとしたいので、400pxからpadding:20px;（左右で40px）とborder:10px;分（左右で20px）を差し引いたものがwidthとなります。</p>
<p>関連情報：<a href="http://www.hp-webmagic.com/wordpress/archives/127" title="DOCTYPE宣言とレタリングモード表">DOCTYPE宣言とレタリングモード表</a></p>
<h4>標準準拠モードによるwidth指定サンプル1</h4>
<p>実際の指定にありうるパターンで解説します。</p>
<ul>
<li>サイドバー部分200px（#sidebarとする）</li>
<li>余白を左右に10px（今回はpaddingとする）</li>
</ul>
<pre>#sidebar{
    <span>width: 180px;</span>
    float: right (or left);
    <span>padding: 0 10px;</span>
}</pre>
<p>表示上での幅は200pxですが、実際に#sidebar内に記述できるのは180pxという点に注意。180pxを超えるバーナーやイメージ画像等を入力するとサイドバーがもしくは本文部分が落ちます。</p>
<h4>標準準拠モードによるwidth指定サンプル2</h4>
<p>ウェブサイトの段組みを例にしてみます。</p>
<ul>
<li>全体の幅を700px（#wrapperで包括）</li>
<li>記事部分を500px,左寄せ（#contentとする）</li>
<li>記事部分の余白を左右に10px（今回はpaddingとする）</li>
<li>記事部分の右側にborder（1pxとする）</li>
<li>サイドバー部分200px,右寄せ（#sidebarとする）</li>
<li>余白を左右に10px（今回はpaddingとする）</li>
</ul>
<pre>#wrapper{ width: 700px; }

#content{
<span>width: 479px;</span>
float: left;
<span>padding: 10px;
border-right: 1px solid #000;</span>
}

#sidebar{
width: 180px;
float: right;
padding: 10px;
}

#footer{ clear: both;}</pre>
<p><span>標準準拠モードは width 及び height  に padding 及び border を含まないので、borderの1px分も差し引きます。</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hp-webmagic.com/wordpress/archives/181/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

