
個人用メモ
| ブロック(div 区切り)のレイアウト | ||
|---|---|---|
・左上が基点 ・IDは任意。わかりやすい名前をつけないと後でわからなくなる ×style1 やstylec などはダメ |
||
左揃えなら右の空白、 左揃え margin-right: auto; (または margin:0px auto 0px auto;)
フロート float float: right; 右寄せ
|
フロートを % で指定する場合 合わせた数値が100% だとレイアウトがくずれる。99%以下にする。 floatしている要素の親要素にclearを指定するとレイアウトがくずれる。 |
|
中央揃え
|
||
[html body より ] <body> <div id="box"> </div> </div> </div> |
[CSS] body{ text-align:center; font-family: "MS Pゴシック", Osaka, "ヒラギノ角ゴ Pro W3"; font-size:small; color: #000000; background-image: url(image/back.gif);} #box{ width: 770px; text-align:left; margin:0px auto 0px auto;} #header{ width: 770px;height: 100px; background: url(image/tittle.jpg) no-repeat;} #menu{ float: left; width: 140px; margin:0px auto 0px auto;} #content{ float: right; width: 600px; margin: 0px; padding: 10px;} #footer{ width: 750px; margin-right: auto; margin-left: auto; padding: 10px; clear: both; } |
body 全体を指定 IE6用に、body に text-align:center; を加える 背景は指定なしだとタイル状に並べられる box で中央揃えにする header 背景として画像を入れた時
menu 左寄せ content 右寄せ footer 回り込みを防ぐために clear: both; を入れる |