ホームページ  >  記事  >  ウェブフロントエンド  >  助けを求めている初心者: なぜ中央に表示できないのですか? _html/css_WEB-ITnose

助けを求めている初心者: なぜ中央に表示できないのですか? _html/css_WEB-ITnose

WBOY
WBOYオリジナル
2016-06-24 12:08:221022ブラウズ

CSS コードは次のとおりです:

body{ margin:0; text-align:center;}
div#heard{background:url(images/hd.gif) no-repeat; }
div #pagebody{ 背景:url(images/content.gif) 繰り返しなし; パディング:0 15px; }
div#footer{ 背景:url(images/ft.gif) 繰り返しなし; :100px; :padding-top:30px;}

HMTL は次のとおりです:

93f0f5c25f18dab9d176bd4f6de5d30e
97f2b6ae5f4f65bc7d15c6c9b9e8be8c
a1a60f10daef83547af1bec9c8d40f8a
9c3bca370b5104690d9ef395f2c5f8d1 ;
d3566e992d46985536e02e637a79f3e316b28748ea4df4d9c2150843fecfba68
171c8477c82d74a9b2eea84eaab9316716b28748ea4df4d9c2150843fecfba68 36cc49f0c466276486e50c850b7e4956
開くと左揃えになっていますが、どこが間違っているのでしょうか?




ディスカッションへの返信 (解決策)

* { margin: 0 auto;
}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    <title>实例</title>    <style>        body        {            text-align: center;        }        div#main        {            margin-right: auto;            margin-left: auto;            width: 400px;            vertical-align: middle;            line-height: 200px;        }        div#heard        {            background: url(images/1.jpg) no-repeat;            height: 132px;        }        div#pagebody        {            background: url(images/1.jpg) no-repeat;            height: 538px;        }        div#footer        {            background: url(images/1.jpg) no-repeat;            height: 100px;        }    </style></head><body>    <div id='main'>        <div id="heard">        </div>        <div id="pagebody">        </div>        <div id="footer">        </div>    </div></body></html>


  body        {            text-align: center;        }

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。