1

幅1600pxのページがあります。ただし、メイン エリアの幅はわずか 900px です。ページの中央に固定されると思われるナビゲーションがあります (これは )。私の問題は、ページを開くと、開いたときにページが中央に配置されるのではなく、左に固定されることです。ユーザーがサイトにアクセスしたときに、すべてを 900px の中央に配置するにはどうすればよいですか?

コードは詳細であるため正確ではありませんが、基本的には次のようになります: http://jsfiddle.net/wznQk/

<body>
    <div class="container">
        <div class="header">
            <div class="subheader">
                <div class="navigation">
                    <ul>
                        <li>HOME</li>
                        <li>ABOUT</li>
                        <li class="logo"><img src="images/ogsystemslogo.png" /></li>
                        <li>CAREERS</li>
                        <li>CONTACT</li>
                    </ul>
                </div>

                    <div class="undernav">
                        <div class="short">
                            <img src="images/bluemark.png" />
                            <div class="top">TOP OGS NEWS:</div>
                        </div>
                   </div>
            </div>
        </div>
        <div class="content">
        </div>
    </div>
</body>

CSS

.body {
    width: 1600px;
    height: 100%;
    margin: 0 auto;
    padding: 0px;
    border: 0px;
    position: relative;
    text-align: center;
}

.container {
    width: 1600px;
    height: 100%;
    position: relative;
    margin: 0 auto;
    padding: 0px;
    border: 0px;
    text-align: center;
}

.header {
    width: 1600px;
    height: 150px;
    margin: 0 10% 0 10%;
    padding: 0px;
    border: 0px;
    background-color: white;
    position: fixed;
}

.subheader {
    width: 1600px;
    height: 100px;
    margin: 0 auto;
    position: fixed;
    background-color: white;
    top: 0px;
}

.navigation {
    font-family: 'Champagne & Limousines';
    font-size: 20px;
    text-align: left;
    width: 1600px;
    height: 100px;
    padding: 0px;
    margin-left: 0 auto;
    border: 0px;
    list-style: none;
    text-decoration: none;
    display: table-cell;
    vertical-align: middle;
    color: #006699;
    background-color: white;
}

    .navigation ul {
        width: 590px;
        height: 20px;
        list-style: none;
        text-decoration: none;
        position: relative;
        line-height: 55px;
        margin: 0 auto;
        background-color: white;
        padding: 0px;
        border: 0px;

    }

    .navigation ul li {
        width: 70px;
        height: 15px;
        float: left;
        padding-left: 35px;
        background-color: white;
    }
4

2 に答える 2

0

あなたの代わりにこの CSS を追加してみてください。あなたの CSS には不要な CSS タグがたくさん見つかりましたが、そのままにしておきます。

body {
    width: 1600px;
    height: 100%;
    margin: 0 auto;
    padding: 0px;
    border: 0px;
    position: relative;
    text-align: center;
}
.container {
    width: 900px;
    height: 100%;
    position: relative;
    margin: 0 auto;
    padding: 0px;
    border: 0px;
    text-align: center;
}
.header {
    width: 1600px;
    height: 150px;
    padding: 0px;
    border: 0px;
    background-color: white;
    position: fixed;
}
.subheader {
    width: 900px;
    height: 100px;
    position: fixed;
    background-color: white;
    top: 0px;
}
.navigation {
    font-family: 'Champagne & Limousines';
    font-size: 20px;
    text-align: left;
    width: 590px;
    height: 100px;
    padding: 0px;
    margin: 0 auto;
    border: 0px;
    list-style: none;
    text-decoration: none;
    vertical-align: middle;
    color: #006699;
    background-color: white;
}
.navigation ul {
    width: auto;
    height: 20px;
    list-style: none;
    text-decoration: none;
    position: relative;
    line-height: 55px;
    background-color: white;
    padding: 0px;
    border: 0px;
}
.navigation ul li {
    width: 70px;
    height: 15px;
    float: left;
    padding-left: 35px;
    background-color: white;
}
于 2013-08-22T09:32:20.247 に答える