2012-01-11 98 views
-1

完全不可思議,我無法修復它,所以它居中...最後,我玩弄了不同的寬度%,並得出結論,減少%讓它居中......但似乎倒退.. ..有人只是解釋爲什麼它這樣做....我的意思是我得到它的工作,但我不想在我的大腦中燒掉這種技術,如果它只有一個委婉或什麼....請解釋降低寬度%允許居中表單?

HTML代碼

<form action="mailto:[email protected]" method="post"> 
      <input type="text" id="fName" maxlength="20" size="30" placeholder="First Name" required="required" autocomplete="on"><br /> 
      <input type="text" id="lName" maxlength="20" size="30" placeholder="Last Name" required="required" autocomplete="on"><br /> 
      <input type="email" id="email" maxlength="30" size="30" placeholder="Email" required="required" autocomplete="on"><br /> 
      <textarea name="message" rows="5" cols="30" maxlength="100" wrap="hard" placeholder="Message..." required="required" /></textarea></p> 
      <input type="submit" name="submit" value="Submit" /> 
      <input type="reset" name="clear" value="Clear" /> 
      </form> 
</body>  
</html> 

這裏是窗體的CSS代碼....我想100%,它沒有工作......後來終於不得不靜下心來,25%,以居中。 ...你可以在www.saucysbulldogs.com看到它

form { 
padding:10px; 
width:25%; 
margin-left:auto; 
margin-right:auto; 
}  

感謝

回答

0

,你不能以100%的寬度中心的元素應該是你很清楚。 當你保持較低的百分比和邊距爲0的時候,它會以中心爲中心。

但是沒有必要下降到25%。

當我看你的網址時,我沒有看到任何問題。您的表單寬度爲85%,並且位於其父容器中。