2011-01-04 6 views
-1

これまで私が一度も見たことのない奇妙な問題を抱えています...私たちが知っているように、divはボディの内側にあり、ボディマージン0とパディング0を作ることができますページ全体を高さと幅100%でカバーしています...問題は、体内のdivをマージンしようとすると、体全体が動いてしまいます。私は火か虫を使って身体の上を動かすと驚いていますページ全体ではありません。HTML、本文、divで何か問題があります

<!DOCTYPE HTML> 
<html> 
<head> 
    <!-- Styles --> 
    <link rel="stylesheet" type="text/css" href="styles/general-style.css"/> 
    <link rel="stylesheet" type="text/css" href="styles/css-buttons.css"/> 
    <link rel="stylesheet" type="text/css" href="styles/css-colors.css"/> 

    <!-- Scripts --> 
    <script type="text/javascript" src="scripts/jquery-1.4.4.min.js"></script> 

    <script type="text/javascript"> 
    </script> 
</head> 
<body> 
    <div id="content"></div> 
    <div id="footer"> <!-- footer div starts here --> 
    </div> <!-- footer div starts here --> 
</body> 
</html> 

CSS::ところでこれだけ

html{ 
} 

body{ 
    width: 100%; 
    height:100%; 
    padding: 0; 
    margin: 0; 
} 

#content{ 
    background: red; 
    margin-left: auto; 
    margin-right: auto; 
    margin-top: 100px 
    height: 350px 
    width:350px 
} 

#footer{ 
    margin-left:auto; 
    margin-right:auto; 
} 

#footer-text{ 
    font-size:xx-small; 
    margin-top:30px; 
    text-align:center; 
} 
+0

が '' タグを閉じてお試しください。 – rxgx

+1

@rxgx:これは必須ではありません。 –

答えて

2

そのダイビングよりもわずかに大きい...ここにコードがある

HTML(最初の部分は、第二のCSSで、HTMLです)仕事、マージン崩壊。あなたは何をしようとしているのですか? HTMLタグに背景色を設定したり、CSSのtop/leftプロパティを使用してdivを配置したりできます。

も参照してください:TJHeuvelは、すでに述べたように、これはマージンを崩壊さhttp://www.w3.org/TR/CSS21/box.html

0

HTMLコードを

<!DOCTYPE HTML> 
<html> 
<head> 
    <!-- Styles --> 
    <link rel="stylesheet" type="text/css" href="styles/general-style.css"/> 
    <link rel="stylesheet" type="text/css" href="styles/css-buttons.css"/> 
    <link rel="stylesheet" type="text/css" href="styles/css-colors.css"/> 

    <!-- Scripts --> 
    <script type="text/javascript" src="scripts/jquery-1.4.4.min.js"></script> 

    <script type="text/javascript"> 
    </script> 
</head> 
<body> 
    <div id="content"></div> 
    <div id="footer"> <!-- footer div starts here --> 
    </div> <!-- footer div starts here --> 
</body> 
</html> 

CSS

html{ 
} 

body{ 
    padding: 0; 
    margin: 0; 
} 

#content{ 
    background: red; 
    margin-left: auto; 
    margin-right: auto; 
    margin-top: 100px 
    height: 350px 
    width:350px 
} 

#footer{ 
    margin-left:auto; 
    margin-right:auto; 
} 

#footer-text{ 
    font-size:xx-small; 
    margin-top:30px; 
    text-align:center; 
} 

この

関連する問題