0

申し訳ありませんが、私はこれで完全に新しいです。このサイトhttp://www.jellyneo.net/index.phpのように、ページの中央にすべてが入るボックスを作成できるように、div を作成しようとしています。

私のHTMLは次のようになります。

<!DOCTYPE HTML PUBLIC>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="CSSdoc.css" />
    </head>
    <body>
        <center>
            <div id="mainbox">
                <p>text</p>
            </div>
        </center>
        <h1> text </h1>
        <p>text</p>
        <h2> text </h2>
        <p>text</p>
    </body>
</html>

そして、私が行ったCSSは次のようになります

#mainbox {
    width: 900px
    text-align: left
}

私は何を間違っていますか?

4

2 に答える 2

0

<center>HTML コードにタグは必要ありません。CSS は物事を中心に置くのに役立ちます。CSSdoc.css ファイル内で、次のように調整するだけです...

#mainbox {
    padding: 0;
    margin: 0 auto; /*the 0 here represents the top and bottom margin spacing. it's good to have and control in many cases.*/
    width: 900px;
    border: solid 2px #000; /*this is optional, more for debugging purposes to see your 900px scaled box*/
}
于 2013-06-27T21:20:11.320 に答える