Div CSS 共通レイアウトコード collection_html/css_WEB-ITnose

WBOY
リリース: 2016-06-24 11:25:32
オリジナル
1799 人が閲覧しました

これで、すべてに Div CSS レイアウトが追加されました。この記事では、2 行 1 列、3 行 1 列、2 行 2 列、3 行 2 列、2 行などの一般的に使用される DivCSS レイアウト コードを収集して整理します。行 3 列、1 行 3 列、float 位置決めコードのコレクション。各レイアウトのコードを以下に 1 つずつ掲載します:

CSS 1 行 1 列のレイアウト コード:

body{margin:0px;padding:0px;text-align:center;}#content{margin-left:auto;margin-right:auto;width:400px;width:350px;}
ログイン後にコピー

CSS 2 行 1列レイアウト コード:

body{margin:0px;padding:0px;text-align:center;}#content-top{margin-left:auto;margin-right:auto;width:400px;width:350px;}#content-end{margin-left:auto;margin-right:auto;width:400px;width:350px;}
ログイン後にコピー

CSS 3 行 1 列レイアウト コード:

body{margin:0px;padding:0px;text-align:center;}#content-top{margin-left:auto;margin-right:auto;width:400px;width:320px;}#content-mid{margin-left:auto;margin-right:auto;width:400px;width:320px;}#content-end{margin-left:auto;margin-right:auto;width:400px;width:320px;}
ログイン後にコピー

Div CSS 3 行 2 列レイアウト:

#header{width:700px;margin-right:auto;margin-left:auto;}#bodycenter{width:700px;margin-right:auto;margin-left:auto;}#bodycenter#dv1{float:left;width:280px;}#bodycenter#dv2{float:right;width:410px;}#footer{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}
ログイン後にコピー

2 行 2 列レイアウト:

#header{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}#bodycenter{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}#bodycenter#dv1{float:left;width:270px;}#bodycenter#dv2{float:right;width:350px;}
ログイン後にコピー

1 行 2 列レイアウト:

#bodycenter{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}#bodycenter#dv1{float:left;width:280px;}#bodycenter#dv2{float:right;width:410px;}
ログイン後にコピー

絶対配置 CSS コードを使用した 1 行 3 列:

#left{position:absolute;top:0px;left:0px;width:120px;}#middle{margin:20px190px20px190px;}#right{position:absolute;top:0px;right:0px;width:120px;}
ログイン後にコピー

float 配置 CSS コードを使用した 1 行 3 列:

<style>#wrap{width:100%;height:auto;} #column{float:left;width:60%;} #column1{float:left;width:30%;} #column2{float:right;width:30%;} #column3{float:right;width:40%;} .clear{clear:both;}<style><divid="warp"> <divid="column"> <divid="column1">第一列</div> <divid="column2">第二列</div> <divclass="clear"></div> </div> <divid="column3">第三列</div> <divclass="clear"></div> </div>
ログイン後にコピー

2 行 3 列の完全なコード:

<style>#header{width:100%;height:auto;} #wrap{width:100%;height:auto;} #column{float:left;width:60%;} #column1{float:left;width:30%;} #column2{float:right;width:30%;} #column3{float:right;width:40%;} .clear{clear:both;}</style><divid="header">头部行</div> <divid="warp"> <divid="column"> <divid="column1">第一列</div> <divid="column2">第二列</div> <divclass="clear"></div> </div> <divid="column3">第三列</div> <divclass="clear"></div>
ログイン後にコピー

3 行 3 列のレイアウト、CSS および HTML

<style>#header{width:100%;height:auto;} #wrap{width:100%;height:auto;} #column{float:left;width:60%;} #column1{float:left;width:30%;} #column2{float:right;width:30%;} #column3{float:right;width:40%;} .clear{clear:both;} #footer{width:100%;height:auto;}</style><!--以下引用上边的CSS定义--><divid="header">顶部行</div> <divid="warp"> <divid="column"> <divid="column1">第一列</div> <divid="column2">第二列</div> <divclass="clear"></div> </div> <divid="column3">第三列</div> <divclass="clear"></div> </div> <divid="footer">底部行</div>
ログイン後にコピー

以下のコードでは、margin、padding、boeder などの属性を設定していません。使用する場合は、状況に応じて自分で定義できます。


ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!