Bootstrap中的Grid系统我缺少什么?

时间:2012-08-13 02:50:34

标签: formatting twitter-bootstrap html

请随意纠正我,但根据我对bootstrap CSS的理解,spans1,2,3,4等应该可以轻松地在网页上布局数据。一整行应该是一个span12,意味着两个6跨度应该等于整行,内容为50/50间隔?到目前为止这是对的吗?

<div class="hero-unit">
    <div class ="span4">First name: <input  type="text"  runat="server" placeholder="Enter First Name" name="firstname" id="firstname"/></div>
    <div class ="span4">Last name: <input  type="text"  runat="server" placeholder="Enter Last Name" name="lastname" id="lastname"/></div>
    <div class ="span2">Student Number: <input  type="text"  runat="server" placeholder="Enter Student Number" name="Student Number" id="StudentNumber"/> </div>
    <div class ="span2">Course code & Name:  <input  type="text"  runat="server" placeholder="Enter Course Code" name="CourseCode" id="CourseCode"/></div>
    <div class ="span4">Course code & Name: <input   type="text" runat="server" placeholder="Enter Course Code" name="CourseCode" id="Text1"/> </div>
</div>

结果看起来没有像我期望的那样。这里混乱的表格的图像sample http://img546.imageshack.us/img546/6361/35787686.png

1 个答案:

答案 0 :(得分:1)

再次感谢Tom解决方案代码如下: -

<div class="row-fluid">
  <h1>Personal Details</h1></div><div class="row hero-unit">
  <div class="row-fluid">
    <div class ="span2">First name:</div> 
    <div class="span4">
      <input  type="text"  runat="server" 
              placeholder="Enter First Name" 
              name="Firstname" id="Firstname" />
    </div>
    <div class ="span2">Last name:</div> 
    <div class="span4">
       <input  type="text"  runat="server" 
               placeholder="Enter Last Name" 
               name="Lastname" id="Lastname"/>
    </div>
  </div>
  <div class="row-fluid">
    <div class ="span2">Student Number:</div> 
    <div class="span4"> 
      <input type="text"  runat="server" 
             placeholder="Enter Student Number" 
             name="Student Number" id="StudentNumber"/>
    </div>
    <div class ="span2">Course Name:</div> 
    <div class="span4"> 
      <input type="text"  runat="server" 
             placeholder="Enter Course Code" 
             name="CourseCode" id="CourseCode"/>
    </div> 
  </div>
  <div class="row-fluid">
    <div class ="span2">Mail Address:</div> 
    <div class="span10">
      <input type="text" class="span10" runat="server" 
             placeholder="Enter Postal Address" 
             name="PostalAddress" id="PostalAddress"/> 
    </div>
  </div>
</div>

可以在此处看到更好的格式化结果: - http://imageshack.us/photo/my-images/502/homepageim.png/