• ベストアンサー

IE6にてずれる

こんにちは html超初心者です。 headとcontentsを隙間なく表示したいのですが、IEではコンテンツがずれてしまい うまく表示されません。 コードを記載します。 ================================== --------html------------ <div id="all"> <div id="head"> <h1><a href="../index.html"><img src="img/logo.gif"></a></h1> <div id="guide"> <a href="../index.html">ホーム</a> <a href="index.html">プロフィール</a> <a href="#">リンク</a></div> <p class="clear-both">&nbsp;</p> </div> <div id="contents"> コンテンツ内容 </div> </div> --------css------------ body,a,div,p,h1,h2,h3,ul,li,img,dl,dd,dt,ol{ margin:0; padding:0; text-decoration: none; } #all{ width:650px; } .clear-both{ font-size:0; height:0px; clear:both; line-height:0%; } #head{ width:650px; background:url('../img/main_img.gif') no-repeat; height:90px; } #guide{ float:right; margin:60px 0px 0px 0px; } #contents{ background:url('../../common/img/back_img.gif') repeat-y ; } ================================== headにてボックスを二つ挿入し、それらをそれぞれfloat:left・rightで左右に表示しています。 その下に<p class="clear-both">&nbsp;</p> を挿入し、cssにてそのクラスに対し、 clear:both; line-height:0%; 等を入力しています。 IEにて確認すると、その下のコンテンツが 右にずれてしまっています。 line-height:0%;がcssに記載されていなければ ずれずに表示されますが、headとcontentsの間に 隙間ができてしまいます。 line-height:0%を記載していてもfirefox・operaではcontentsはずれず、隙間もありません。 どなたか教えてください。 よろしくお願いします。

  • HTML
  • 回答数2
  • ありがとう数3

質問者が選んだベストアンサー

  • ベストアンサー
  • aqucent
  • ベストアンサー率39% (78/200)
回答No.2

とりあえず、<p class="clear-both">&nbsp;</p> は不要です。 恐らく、<div id="guide"> の回り込み解除のためのタグ(CSS)だと思われますが、 親要素に <div id="head"> があるので、回り込みを解除する必要はありません。 回り込みはブロックレベル要素の中で完結します。 > IEにて確認すると、その下のコンテンツが右にずれてしまっています。 <div id="head"> で括られているのですから、当然でしょう。 というより、括られていない動作をお望みなのでしょうか。 <div id="all"> <div id="head"> <h1><a href="../index.html"><img src="img/logo.gif"></a></h1> </div> <div id="guide"> <a href="../index.html">ホーム</a> <a href="index.html">プロフィール</a> <a href="#">リンク</a> </div> <br style='display: none; clear: both'> <div id="contents"> コンテンツ内容 </div> </div> "clear-both" については、#1 の方と同様、空要素を使うことをお勧めします。 p要素や「空白」で余白を取る形はお勧めできませんので…。(margin, padding辺りで余白を取るのが一般的です) 質問者さんのやりたいことを考えると、CSSは "display: none" が適切だと思います。 個人的には、"float: right" より、"float: left" の方をお勧めします。 例文では、「コンテンツ内容」は1つですが、その下にもう一つ「コンテンツ内容」を続けると、 後で、htmlソースを見たときに順番が把握しづらくなります。 <div id="body"> <div style="float: left; margin-right: 5em"> コンテンツ内容1 </div> <div> <a href="../index.html">ホーム</a> <a href="index.html">プロフィール</a> <a href="#">リンク</a> </div> </div> <div id="contents"> コンテンツ内容2 </div> 初めに説明しましたが、予めブロックレベル要素で括っておけば、"clear: both" が不要となります。

参考URL:
http://www.nextindex.net/web/CSS/formatting.html#display
naokichi000
質問者

お礼

<p class="clear-both">&nbsp;</p> 消したらできました! 回り込みはブロックレベル要素の中で完結するんですね! どんなときも回り込みをした時はclear-bothがないとくずれると信じて疑っていませんでした! ご丁寧なご回答本当にありがとうございましたm(__)m

その他の回答 (1)

  • mognol_n
  • ベストアンサー率61% (8/13)
回答No.1

私が使っている方法ですが… 1.CSSの.clear-bothを .clear-both{ clear:both; } だけにする 2.<p class="clear-both">&nbsp;</p>を、 <br class="clear-both">に置き換える 以上で直らないでしょうか?

naokichi000
質問者

お礼

早速のご回答ありがとうございます。 <br class="clear-both">に置き換えることでできました! しかし今回は#2の方のご回答で<p class="clear-both">&nbsp;</p>を消してやることにしました。 これからはmognol_nさんの言うとおり、clear-bothをつける時は、brタグにつけたいと思います。 ご回答本当に、ありがとうございました。m(__)m

関連するQ&A

  • IE6で隙間ができてしまう

    IE6でヘッダーとコンテンツの間に隙間ができてしまいます。 IE7、Firefox、Safariでは問題なく表示されています。 [HTML] <div id="top"> <div id="topcont"> <h1><a href="http://www.AAA.com/"><img src="img/AAA.gif" />AAA</a></h1> </div></div> <div id="navi"> <div id="navicont"> <ul> <li id="home"><a href="http://www.AAA.com/" title="AAA">AAA</a></li> <li id="BBB"><a href="http://www.AAA.com/BBB.html" title="BBB">AAAについて</a></li> <li id="CCC"><a href="http://www.AAA.com/CCC.html" title="CCC Lesson">CCC</a></li> </ul> </div> </div> [CSS] #top { background: url(img/IIIII.jpg) repeat-x; margin: 0px; padding: 0px; height: 80px; } #topcont { background: url(img/III.jpg) repeat-x; margin: 0px auto; padding: 0px; height: 80px; width: 900px; } #navi { background: url(img/NNN.gif) repeat-x; text-align: center; margin: 0px; padding: 0px; height: 35px; } #navicont { margin: 0px auto; padding: 0px; height: 35px; width: 900px; } 隙間を無くすにはどうすればよいのでしょうか。 わかる方いらっしゃいましたら、よろしくお願い致します。

    • ベストアンサー
    • HTML
  • CSSで画面を構成しています。

    CSSで画面を構成しています。 左ブロック、右ブロック共に角丸の四角にしたいので、**_head.gifというようなフタとソコになるような画像を使っています。 このままだと左右ブロックの高さが当然そろわないのですが、何か良い方法はないでしょうか? テーブルレイアウト以外であれば、多少イレギュラーな方法でもかまいません。 *css********** div#body{width:800px; margin:10px auto; text-align:center; padding:0; } div#header{padding:0; margin:0 0 10px 0; background-image:url(**.gif); width:800px; height:50px; text-align:left; } div#main{ width:800px; text-align:left; } div#submenu{padding:0; margin:0 10px 10px 0; width:200px; text-align:left; float:left; } div#contents{padding:0; margin:0 0 10px 210px; width:590px; text-align:left; } div#footer{padding:0; margin:0 0 5px 0; clear:both; width:800px; height:30px; text-align:left; } *html**** <div id="body"> <div id="header"> ヘッダー </div> <div id="main"> <div id="submenu"> <img src="img/common/sub_head.gif" width="200" height="10" />  <div>左ブロック</div> <img src="img/common/sub_foot.gif" width="200" height="10" /> </div> <div id="contents"> <img src="img/common/main_head.gif" width="590" height="10" />  <div>右ブロック</div> <img src="img/common/main_foot.gif" width="590" height="10" /> </div> </div> <div id="footer"> フッター </div> </div>

    • ベストアンサー
    • HTML
  • スタイルシートに関しての質問です。margin0 padding0と指定し居るのに、変なスペースが入ってしまいます。。。

    スタイルシートで、 *{ padding:0; margin:0; } img{ padding:0; margin:0; } と指定しているのですが、なぜか画像でへんなスペースが入ってしまいます。どうしてでしょうか? ソースは下記の通りです。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <head> <META http-equiv=Content-Type content="text/html; charset=Shift_JIS"> <META content="新築マンション,賃貸,敷金ゼロ,礼金ゼロ,ペット可,内覧可能,水商売可,風俗可,東京,都内,マンション,アパート,一戸建, name=keywords> <title>株式会社</title> <link href="css/mainstyle.css" rel="stylesheet" type="text/css"> </head> <body> <div id="wapper"> <div id="head"><img src="img/forward_rogo.gif" width="250" height="56" border="0" ></div> <div id="sidememu"> <table width="150" border="0" cellpadding="0" cellspacing="0" > <tr> <td><a href="#"><img src="img/menu1.gif" width="150" height="40" border="0"></a></td> </tr> <tr> <td><a href="#"><img src="img/menu13_h.gif" width="150" height="40" border="0"></a></td> </tr> <tr> <td><a href="#"><img src="img/menu5_h.gif" width="150" height="40" border="0"></a></td> </tr> <tr> <td><a href="#"><img src="img/menu4.gif" width="150" height="40" border="0"></a></td> </tr> <tr> <td><a href="#"><img src="img/menu11_h.gif" width="150" height="40" border="0"></a></td> </tr> <tr> <td><a href="#"><img src="img/menu10_h.gif" width="150" height="40" border="0"></a></td> <tr> <td><a href="#"><img src="img/menu3.gif" width="150" height="40" border="0"></a></td> <tr> <td><a href="#"><img src="img/menu9_h.gif" width="150" height="40" border="0"></a></td> <tr> <td><a href="#"><img src="img/menu6_h.gif" width="150" height="40" border="0"></a></td> <tr> <td><a href="#"><img src="img/menu8_h.gif" width="150" height="40" border="0"></a></td> </tr> </table> </div> <div id="main"> <div id="flash-a"> <img src="img/dammy.gif" width="650" height="150" border="0"> </div> <div id="main-1"> <img src="img/top_1.gif" width="650" height="40" border="0"> </div> </div> </div> </body> </html> cssは、 /* CSS Document */ *{ padding:0; margin:0; } img{ padding:0; margin:0; } body{ margin-left:auto; margin-right:auto; text-align:center; } #wapper{ width:820; } #head{ margin-top:20px; text-align:left; border-bottom:2px #000099 solid; } #sidememu{ margin-top:20px; background-color:#F00; float:left; } #main{ margin-left:10px; margin-top:20px; float:right; } です。すみません。教えてください!

  • 擬似フレームを中央に表示したい。

    ただいまHP作成に奮闘中の者です。 いつもはネットでちくちくと検索をしながらhtml等について学びながら作成しているのですが、今回検索エンジンでも上手くヒットしなく、しばらく行き詰まってしまったので質問させてください。 現在擬似フレームを使ってHPのTOP画面が6割ほどできたのですが全てが左に寄っています。 それを中央に表示させたいのですが、どうすればよいのでしょうか? ■■■□□ ■■■□□  これを↓ ■■■□□ ■■■□□ □■■■□ □■■■□  この様にしたい □■■■□ □■■■□ 以下タグです。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <meta http-equiv="Content-Style-Type" content="text/css"> <title>タイトル</title> <!-- ------ FLASH ACTIVATION SCRIPT--------> <script src="flash_activate.js" type="text/javascript"></script> <!-- ------ FLASH ACTIVATION SCRIPT--------> <script src="flash_activate.js" type="text/javascript"></script> <style type="text/css"> <!-- body { margin:0px; padding:0px; } #top { width:450px; height:120px; float:left; background-color:#3399ff; } #tops { width:300px; height:120px; float:left; background-color:#ffcc33; } #topss { width:750px; height:280px; crear:both; background-color:pink; } #left { width:250px; height:100px; float:left; background-color:white; } #menu1 { width:250px; height:100px; clear: both; } #menu2 { width:250px; height:100px; clear: both; } #menu3 { width:250px; height:100px; clear: both; } #menu4 { width:250px; height:100px; clear: both; } #menu5 { width:250px; height:100px; clear: both; } #menu6 { width:250px; height:100px; clear: both; } #middle { width:300px; height:600px; float:left; background-color:white; } #right { width:200px; height:600px; float:left; } #under { width:750px; height:10px; clear: both; background-color:#cc66cc; } --> </style> </head> <body> <div id="top">ここにHPロゴ</div> <div id="tops">ここに説明やテーブル</div> <br style="clear:both" /> <div id="topss"></div> <div id="left"> <div id="menu1"><A Href="http://www.yahoo.co.jp/"><Img Src="about_us.png"></A></div> <div id="menu2"><A Href="URL"><Img Src="member.png"></A></div> <div id="menu3"><A Href="URL"><Img Src="movie.png"></A></div> <div id="menu4"><A Href="URL"><Img Src="blog.png"></A></div> <div id="menu5"><A Href="URL"><Img Src="link.png"></A></div> <div id="menu6"><A Href="URL"><Img Src=""></A></div> </div> <div id="middle">更新履歴など</div> <div id="right"> </div> <div id="under"></div> </body> </html> ご回答頂けたら幸いです。 よろしくお願いしますm(_ _)m

    • ベストアンサー
    • HTML
  • IE6にてliタグに対してposition:absolute;を使ったときのバグについて

    すみません、質問させて下さい。 下記のソースとスタイルシートでIE6の場合だけliが原因と思われる余白ができます。他のモダンブラウザ、IE7以降ではhrの部分を除いて問題ありませんでした。余白をなくす方法はないでしょうか。 ソース <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link href="test.css" type="text/css" rel="stylesheet"> <title>test</title> </head> <body> <div id="wrapper"> <div id="header"> <h1>test</h1> </div> <div id="contents"> <div id="lefty"> <p>test test test (略)</p> </div> <div id="righty"> <p>test test test (略)</p> </div> </div> <hr> <div id="navi"> <ul> <li id="list01"><a href="#">赤</a></li> <li id="list02"><a href="#">青</a></li> </ul> </div> <div id="footer"> <address>copyright.</address> </div> </div> </body> </html> スタイルシート @charset "shift_JIS"; * { margin: 0; padding: 0; } body { text-align: center; } #wrapper { margin: 0 auto; width: 760px; position: relative; text-align: left; } #header { width: 760px; height: 100px; background-color: #CC9900; } #contents { width: 760px; } #lefty { width: 380px; float: left; background-color: #CCC; } #righty { width: 380px; float: right; color: #FFF; background: #000 } #list01 a { display: block; width: 180px; padding: 30px 0 0 0; overflow: hidden; background: url(images/nav01.gif) no-repeat; height: 0px !important; height/**/: 30px; position: absolute; top: 30px; right: 0; } #list02 a { display: block; width: 180px; padding: 30px 0 0 0; overflow: hidden; background: url(images/nav02.gif) no-repeat; height: 0px !important; height/**/: 30px; position: absolute; top: 60px; right: 0; } #list01 a:hover { display: block; width: 180px; padding: 30px 0 0 0; overflow: hidden; background: url(images/nav01_on.gif) no-repeat; height: 0px !important; height/**/: 30px; position: absolute; top: 30px; right: 0; } #list02 a:hover { display: block; width: 180px; padding: 30px 0 0 0; overflow: hidden; background: url(images/nav02_on.gif) no-repeat; height: 0px !important; height/**/: 30px; position: absolute; top: 60px; right: 0; } #footer { clear: both; padding-top: 30px; width: 760px; background-color: #990033; } li { list-style-type: none; } a { text-decoration: none; } hr { clear: both; width: 0; } どなたかご教授ください、よろしくお願いします。

    • ベストアンサー
    • HTML
  • ieでの微妙な隙間(CSS)

    以下のソースでhtmlを表示するとie6でpage_topとfooterの間に 3~5pxほどの隙間が開いてしまいます。 しかしfirefoxで表示すると隙間なく表示されます。 特にmarginなど指定していないので何が原因なのかが全くわかりません。 どのようにしたらie6でも隙間なく表示できるようになるでしょうか? 以下ソースの抜粋です。宜しくお願いします。 //CSS #page_top { clear: both; width: 900px; height: 24px; margin: 0 auto; padding: 0; background: #fff; text-align: right; } #footer { width: 900px; margin: 0 auto; padding: 10px 0 5px 0; background: #fff url(img/footer_bg.gif) repeat-x; text-align: center; } //html <div id="page_top"> <a href="#top"> <img src="img/btn.gif" alt="ボタン" width="114" height="24" /> </a> </div> <div id="footer"> あいうえおかきくけこさしすせそ・・・ </div>

  • リストタグを用いた縦メニューで画像に隙間ができます(IE6)

    いつも皆さまには助けていただきありがとうございます。 さてまた今回も質問で申し訳ないのですが、リストタグを用いて縦のメニューを作成しています。 IE6でのみメニュー画像の上下に隙間が出来る現象が発生して困っております。(本当は隙間なくしたい) こちらの質問を参考にして左メニューの画像に「display:block;」や「vertical-align:bottom;」を付けてみましたが、変化なしです。 #left img{ border:none; display:block; vertical-align:bottom; } と入れたんですが、記入がおかしいでしょうか? 色々調べてみましたが、これ以上どういじって良いのかよく分かりません。 一部省略していますがソースを載せますので間違いをご指摘いただければ大変助かります。 よろしくお願いします。 【HTML】 <html> <head> <link rel="stylesheet" href="css/ie6.css" type="text/css" /> <title>タイトル</title> </head> <body> <div id="container"> <!--ヘッダー部分--> <div id="header"> <div id="headerImg" title="タイトル"> </div><!--id:headerImgEnd--> <div id="headerMenu"> <ul> <li></li> <li></li> <li></a></li> </ul> </div><!--headerMenuEnd--> </div><!--id#headerEnd--> <div id="contents"> <!--左メニュー--> <div id="left"> <div id="left_menu"> <ul> <li><a href="a.html" id="a" title="a">a</a></li> </ul> <ul> <li id="b" title="b"></li> <li><a href="c.html" id="c" title="c"></a></li> <li><a href="d.html" id="d" title="d"></ul> </div><!--id:left_menuEnd--> </div><!--id:leftEnd--> <!--メイン--> <div id="main"> </div><!--mainEnd--> <!--フッター--> <div id="footer"> </div><!--id:containerEnd--> </div> </body> </html> 【CSS】 body{ margin:0; padding:0; text-align:center; font-size:14px; } #container{ margin:0 auto; width:800px; text-align:left; borer:solid 1px #999; } #header{ width:800px; } div#headerImg{ width:800px; height:138px; background-image:url(img/title.gif); background-color:#00FFcc; } div#headerMenu{ width:800px; } #contents{ width:800px; } /*左メニュー*/ #left{ float:left; width:180px; } #left_menu ul{ list-style:none; padding:0; margin:0; } #a{ background-image:url(../img/a.gif); width:180px; height:69px; display:block; margin-top:0px; margin-left:0px; } #b{ background-image:url(../img/b.gif); background-repeat:no-repeat; width:180px; height:30px; display:block; margin-top:0px; margin-left:0px; } #c{ background-image:url(../img/c.gif); background-repeat:no-repeat; width:180px; height:25px; list-style:none; display:block; margin-top:0px; margin-left:0px; } a#c:hover{ background-image:url(../img/c02.gif); background-repeat:no-repeat; } #d{ background-image:url(../img/d.gif); background-repeat:no-repeat; width:180px; height:24px; list-style:none; display:block; margin-top:0px; margin-left:0px; } a#d:hover{ background-image:url(../img/d02.gif); background-repeat:no-repeat; } /*メイン*/ #main{ float:right; width:620px; margin:-14px 0 0 0; } /*フッター*/ #footer{ clear:both; width:800px; height:47px; }

    • ベストアンサー
    • HTML
  • firefoxで背景が表示されません

    こちらのQAを見て、floatを消してみたりclear入れてみたりしてみましたが一向に変化しません、 navで指定した背景画像がIEでは出てforefoxでは出ません・・どこをどう直したらよいのでしょうか・・・ ------css----------- body{ background:url(img/bg.jpg); padding:0; width: 775px; margin: 0 auto; } wrapper{ padding:0; width:755px; position:relative; } #head { margin: 0px; height: 54px; padding: 0px; } h1{ margin: 0px; padding: 0px; width: 177px; height: 59px; position: relative; top: 0px; right: 0px; background: url(img/logo.jpg) no-repeat; text-indent: -9999px; text-decoration: none; } #head strong { margin: 0px; padding: 0px; height: 15px; font-size: 12px; color: #FFFFFF; position: absolute; top: 3px; line-height: 15px; text-indent: 350px; } #head img { height: 33px; width: 335px; position: relative; top: -44px; float: right; padding: 0px; margin: 0px 10px 0px 0px; } .main_img { background: url(../img/main_img_bg.jpg) no-repeat; width: 755px; height: 390px; display: block; clear: both; margin: 0px; padding: 0px; position: relative; top: -35px; } .main_img .nav { background: url(img/nav_img.png) no-repeat; height: 369px; width: 208px; margin: 0px; padding: 0px; } .clear { clear: both; } .box01 { margin: 0px; padding: 0px; clear: both; width: 755px; } ---------------html----------------- <body> <!-----------------------wrapper(S)------------------------------------> <div id="wrapper"> <!-----------------------head(S)------------------------------------> <div id="head"> <h1>Bar TRACY バートレイシー</h1> <strong>心斎橋・アメ村barのバー</strong> <img src="css/img/head_tel.jpg" alt="06" /></div> <!-----------------------head(E)------------------------------------> <!-----------------------main_img(S)------------------------------------> <div class="main_img"> <!-----------------------menu(S)------------------------------------> <div class="nav"> <ul> <li class="home"><a href="index.html">ホーム</a></li> <li class="menu"><a href="menu.html">メニュー</a></li> <li class="access"><a href="access.html">アクセス</a></li> <li class="staff"><a href="staff.html">スタッフ紹介</a></li> <li class="event"><a href="event">イベント情報</a></li> <li class="contact"><a href="event">お問い合わせ</a></li> </ul> mixi <p>mixiコミュニティ良かったら コミュに遊びに来てください!</p> </div> <!-----------------------nav(E)------------------------------------> </div> <!-----------------------main_img(E)------------------------------------> <div class="clear"></div> <!-----------------------cont(S)------------------------------------> <div class="cont"> <!-----------------------box01(S)------------------------------------> <div class="box01"> <!-----------------------news(S)------------------------------------> <div class="news"> <h2>ニュース</h2> 画像 <p>サンプルテキスト</p> </div> <!-------news(E)--------> <!-----shop_com(S)------> <div class="shop_com"> <p> ショップインコメント</p> </div> <!-----shop_com(E)----> </div> <!---box01(E)---> <!--box01(S)--> <div class="box01"> <!---bana01(S)---> <div class="bana01"> チケット </div> <!--bana01(E)--> <!---shop_info(S)----> <div class="shop_info"> <h2>ショップ情報</h2> 地図 <dl> <dd>TEL:</dd><dt>06-0000-0000</dt> <dd>住所:</dd><dt>大阪市中央区 </dt> </dl> <dd>mail:</dd><dt>m@00000</dt> <!-----shop_info(E)---> </div> <!--box01(S)--> <!----footer(S)----> <div id="footer"> <p>Homeホーム | Menuメニュー | Accessアクセス | Staffスタッフ | Eventイベント | Contactotお問い合わせ</p> </div> <!---footer(E)--> </div> <!--wrapper(E)--> </body> </html>

  • イメージがずれて表示されてしまいます。

    mainのエリア横幅いっぱいにmainphoto.jpgの写真を置きたいのですが、menuの文字分だけ、上に余白ができてしまいます。画像の横幅を小さくすると、上野余白はなくなりますが、今度は左に2pxほどの余白ができます。mainの幅588pxに隙間なく画像を入れる場合はどうしたら良いのでしょうか。 #wrap{ width: 750px; margin-left: auto; margin-right: auto; text-align: left; background-image:url("images/bgmain.gif"); } #first{ width: 750px; background-color: #CC9933; } #menu{ width: 162px; float: left; } #main{ margin-left: 162px; } #footer{ width: 750px; clear: both; } img { margin: 0; padding: 0; border: 0; } ---------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>質問</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="wrap"> <div id="first"> <h1>サイトNAME</h1> <p> </p></div> <div id="menu"> <p>コンテンツ</p> <p>コンテンツ</p> <p>コンテンツ</p> </div> <div id="main"> <img src="images/mainphoto.jpg" width="588" height="230"> <p>テキストは左に隙間がない。</p>  </div> <div id="footer"><p>フッター</p> </div> </body> </html>

    • ベストアンサー
    • HTML
  • DIV内の padding について

    下記のようなCSSとHTMLファイルにてデザインをしています。 main 内にてpaddingを上下左右に10px 有効にしたいのですが、下記のような記述をCSSにした場合、padding が top (bottom?)にしか適用されません。左右に適用させるにはどうすればよいのでしょうか? よろしくお願いします。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <head> <link rel="stylesheet" media="all" type="text/css" href="index.css" /> </head> <body> <div id=wrapper> <div id=header></div> <div id=face></div> <div id=navi></div> <div id=main></div> <div id=footer></div> </div> </body> </html> body { background: url(img/bg.gif); margin: 0 auto; text-align: center; } #wrapper { width: 800; margin: 0 auto; background: #EEE; } #header { clear: both; height: 50px; text-align: left; background: #009 url(img/header.gif) no-repeat; border-bottom: 1px solid #FFF; } #face { clear: both; height: 200px; text-align: left; background: url(img/face.jpg) no-repeat; border-bottom: 1px solid #FFF; } #navi { float: left; width: 130px; height: 550px; background: #009; text-align: center; border-right: 1px solid #FFF; } #main { font-family: Maiandra GD, Verdana, Arial; font-size: 14px; line-height: 20px; text-align: left; padding: 10px; } #footer { clear: both; height: 50px; background: #009 url(img/footer.gif) no-repeat; border-top: 1px solid #FFF; }

    • ベストアンサー
    • HTML