我对网络编程很陌生。
我的head
代码中有一个样式标记,如下所示:
<style type="text/css">
.center {
float: none;
margin-left: auto;
margin-right: auto;
}
我使用twitter bootstrap。我将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 :(得分:1)
这是居中的,但由于div是块元素,除非你给出一定宽度( Example 指定宽度),否则你无法找出差异。
所以试试这个
.center {
float: none;
margin-left: auto;
margin-right: auto;
text-align:center
}
legend{
text-align:left
}
<强> DEMO 强>
答案 1 :(得分:0)
试试这个
.center {
float: none;
margin-left: auto;
margin-right: auto;
text-align:center;
}
答案 2 :(得分:0)
将text-align:center添加到容器div ..
.center {
float: none;
margin-left: auto;
margin-right: auto;
text-align:center;
}
答案 3 :(得分:0)
在表单标记之前使用中心标记。
<center>
<form></from>
</center>