0

したがって、このCSSを使用してdivテーブルを以下のように設定し、ページの上部に中央揃えで固定します。別のdivを設定して中央に配置することはできますが、DIVを一番上のdivより下に配置するのに問題があります。何かアドバイス?

これは、トップDIVのcssです。

.fixedtop
{
    position: fixed;
    top: 0px;
    left: 50%;
    margin: 0 0 0 -400px;
    background-image: url(bannerlogo.jpg);
    width:800px;
    height: 414;
}

これは私がテストした最新のcssです:

.fixedcenter
{
        position:center;
    margin-top: 414px;
    width:800px;
    height: 414px;
}

また、中央揃えに余白のあるパディングとメッシングを使用しようとしました。すべての助けは非常にありがたいです。

4

2 に答える 2

0

「位置」を使用する場合、正しい値は静的、相対、絶対です。divの高さが変わらない場合は、position:absoluteを使用し、「top」を使用して位置を指定できます。

例:2番目の要素に対して次のようなことを行うことができます。

.fixedcenter2 { position:absolute; margin-top: 414px; width:800px; height: 414px; top: 424px //It will be positioned 20px below the first.
}

于 2012-10-18T03:46:43.063 に答える
0

これを試して:

.fixedtop
{
    margin-left: auto;  
    margin-right: auto; 
    border: 1px solid black; /* I only added the borders so that I could*/
                             /* see what was happening more easily.*/
    background-image: url(bannerlogo.jpg); 
    width: 800px; 
    height: 414px;
}

.fixedcenter
{
    border: 1px solid black; 
    margin-left: auto; 
    margin-right: auto; 
    width: 800px; 
    height: 414px;
}

次のようになります。

2 div

于 2012-10-18T04:08:52.317 に答える