2010-09-07 29 views
0

我有一個div中有一個div和1個H1標籤的頁面;爲什麼我的保證金會在整個分部?

我給保證金爲H1和它給保證金的整個DIV

這是爲什麼?

http://craveadeal.com/indexV2.php

這裏是整個代碼:

<style type="text/css"> 
<!-- 
* { 
margin: 0px; 
padding: 0px; 
} 
#wrapper { 
margin-right: auto; 
margin-left: auto; 
background-image: url(image-files/mockupV2.jpg); 
background-repeat: no-repeat; 
height: 555px; 
width: 1040px; 
background-position: center top; 
} 
#wrapper h1 { 
text-align: center; 
font-size: 72px; 
font-family: "Comic Sans MS", cursive; 
text-decoration: blink; 
color: #F07D00; 
background-color: #000; 
margin-right: 125px; 
margin-left: 125px; 
display: block; 
margin-top: 125px; 
} 
--> 
</style> 
</head> 

<body> 
<div id="wrapper"><h1>COMING SOON</h1> 

</div> 
</body> 
+0

當我查看頁面時,不會發生這種情況;什麼瀏覽器顯示該問題?你可以請張貼截圖嗎? – lnrbob 2010-09-07 17:29:43

回答

1

只需添加一個overflow:hidden#wrapper

這應該工作。

1

的問題

它由​​引起:

「在本說明書中,表述 收縮邊際意味着 兩個或更多個框 的相鄰邊距合併形成單個邊距。「

或者更簡單地說:

當兩個 元素的垂直邊距接觸,只與幅度最大 值的元素的保證金 將榮幸,而在該 保證金具有較小的 保證金值的元素將摺疊爲 零。

  1. 添加垂直填充到您的#wrapper

解決方案

您可以修復它。

  • 將邊框添加到您的#wrapper
  • 浮動您的<h1>
  • 相關問題