• ベストアンサー

http://www.jqa.jp/index.html

http://www.jqa.jp/index.html のようにブラウザの横幅を変更しても 内容が左右真中に表示され ていますがこのようにするには、 どのようにすればよいのでしょうか? よろしくお願いいたします。

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

  • ベストアンサー
  • ORUKA1951
  • ベストアンサー率45% (5062/11036)
回答No.2

このような感じですか 最大800px,最小500px内で、ウィンドウ幅の60%で中央に表示される。 とりあえずサンプル・・ Another HTML-lint gateway ( http://openlab.ring.gr.jp/k16/htmllint/htmllint.html ) W3C CSS 検証サービス ( http://jigsaw.w3.org/css-validator/#validate_by_input ) で(HTML4.01Strict)検証済み <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="ja"> <head> <meta http-equiv="content-type" content="text/html; charset=Shift_JIS"> <title>サンプル</title> <meta http-equiv="Content-Style-Type" content="text/css"> <link rev="made" href="mailto:hoge@hoge.com" title="send a mail" > <link rel="START" href="../index.html"> <style type="text/css"> <!-- html,body{ margin:0px;padding:0px;background-color:rgb(200,200,200); } body>div{ width:60%;min-width:500px;max-width:800px;margin-left:auto; margin-right:auto;background-color:white;padding:10px; border:none;} p{text-indent:1em;} div{ margin:0.5em 1em; border:solid 2px blue;} --> </style> </head> <body> <div> <h1>サンプル</h1> <p>http://www.jqa.jp/index.htmlのようにブラウザの横幅を変更しても、内容が左右真中に表示されていますがこのようにするには、どのようにすればよいのでしょうか?</p> <p>よろしくお願いいたします。</p> <div> <p>こんな感じですかね。</p> </div> </div> </body> </html>

noname#244833
質問者

お礼

お二方ともご回答をありがとうございました! どちらをベストアンサーにするか迷ったのですが、 W3C CSS 検証サービス のURLを張ってくださった ORUKA1951さんにさせて頂きます。 naokitaさん,ORUKA1951さん 本当にありがとうございました!

すると、全ての回答が全文表示されます。

その他の回答 (1)

  • naokita
  • ベストアンサー率57% (1008/1745)
回答No.1

数質問前にも似たような質問が・・・。 似たような回答をしますが、 ------------------------------------------------------- <body style="text-align: center;"> <div style="margin-left: auto; margin-right: auto;"> ここにコンテンツ </div> </body>        ||    枠も文字も真ん中    || ------------------------------------------------------- <body style="text-align: center;"> <div style="margin-left: auto; margin-right: auto; text-align: left;"> ここにコンテンツ </div> </body>        || 枠が真ん中 文字は左      ||  

すると、全ての回答が全文表示されます。

関連するQ&A