2013-03-26 41 views
0

我對網絡編程非常陌生。表單元素不會移動到中心

我有我的head標籤內的樣式標籤是這樣的:

<style type="text/css"> 
    .center { 
     float: none; 
     margin-left: auto; 
     margin-right: auto; 
    } 

我使用Twitter的引導。我有我的form包裹div

<div class="center" 
    <form> 
     <fieldset> 
     <legend>Legend</legend> 
     <label>Label name</label> 
     <input type="text" placeholder="Type something…"> 
     <span class="help-block">Example block-level help text here.</span> 
     <label class="checkbox"> 
      <input type="checkbox"> Check me out 
     </label> 
     <button type="submit" class="btn">Submit</button> 
     </fieldset> 
    </form> 
</div> 

內但form元素,甚至沒有移動到中心。

我在哪裏犯錯?

+0

試試這個: .center { 文本對齊:中心; } 或將div標記替換爲

...
2013-03-26 07:28:41

回答

1

這是中心,但因爲DIV是塊元素,你無法找出區別,除非你給了某些寬度(Example與指定的寬度)

那麼試試這個

.center { 
     float: none; 
     margin-left: auto; 
     margin-right: auto; 
    text-align:center 
    } 
legend{ 
    text-align:left 
} 

DEMO

0

試一下這個

.center { 
    float: none; 
    margin-left: auto; 
    margin-right: auto; 
    text-align:center; 
} 
0

添加文本對齊:中心到div容器..

.center { 
     float: none; 
     margin-left: auto; 
     margin-right: auto; 
     text-align:center; 
    } 

小提琴:http://jsfiddle.net/xhjHS/

0

使用中心標記形式標記之前。

<center> 
<form></from> 
</center>