在进行自己的后台改版时,大体布局都使用了bootstrap,剩下的表单部分没理由不去使用它,对于表单的美化和布局,bootstrap做的也是很不错的,有大气的边框,多功能的按钮及宏观的表单布局,一切都是那么的完整与完美!
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnIAAAC+CAIAAAA++XUkAAALG0lEQVR4nO3dy07j2hYF0Pqn/P8fRCLlxlHpSLgRkTSRDiKoDJLPbVzdEjdP77CyvVcYowUmsbcszzVxwuPHDgAI8mPuBQDA/VCrABBGrQJAGLUKAGHUKgCEUasAEEatAkAYtQoAYdQqAIS5Va0uFovw535lnwBQweVaXVxy5okTdzj9iRdXCwAzmlSrEz8tKuApfXx1owPALIJr9er97P6/TafsAQBaM2et7t10Hq1Vt6oAJBL53ur0Wj36sbtVALKb573VKbV6cW/uWQFozQwvAv9pzaPbT+1n71kA0KB6LwIfPubU0w/3c/RLKhaA1tS7W72481O1erR9dSoADZqzVk89/mKJ6lQA2nShVs+8Hrv3aVSn7j5V6am3Y684HABUME+tTvzhps9bJm4EgBmdq9WL5fen2KI69dSvzahPAFLwj+EAIIxaBYAwahUAwqhVAAijVgEgjFoFgDBqFQDCqFUACKNWASCMWgWAMGoVAMKoVQAIo1YBIMyPRwAgyI9/AYAgahUAwqhVAAijVgEgjFoFgDBqFQDCqFUACKNWASCMWgWAMGoVAMKoVQAIo1YBIIxaBYAwahUAwqhVAAijVuMNw9D3/Wq1WtK8ruv6vh+GYe6r5hsRkEQE5ApqNdgwDD9//lyv18/Pz//QvOfn5/V6vVqtDI46BCQXAbmCWg3W9/16vd7tdsMwvNO8YRh2u916ve77fu5r51sQkFwE5ApN1OpisZh7CWFWq9XLy8vHx8c4jnOvhcvGcfz4+Hh5eem67tbHmn6d31Mi9ghILjUDcjeCa3VxyZknxq5kLsvlchgGIyORcRyHYVgulxWOdXidn0rHfz8tzVH7BCSdmgG5D/G1OvHTqwu4ccvl8v39fe5VUOb9/f3WU+PUFX74wdFPJ36pfQKSUYWA3JM5a3X6fh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yZ+HnXn8xSWW1urnPU883K3r8OIp+vqS1CpAC2LuVv902L9nq2XixvPLmLiqo3fJgTemp45YdMu+9+Ar2vcPtQrQgoBaPXpXevQxh1Vxo1o9dav6uaK+0mGnjnj48fmvHtbqxZ2folYBWhDwIvDnTw+/tNdkew++Ra2eabUb3a1e/MZiYoWrVYDsYu5WJ7ZFtVrdK/Xpd6KlvTvlG4vD7acOp1YBsot8EfjUls/tstdwt6jVwzVMr6vDXpx4ozn9QOdrdfqx9qhVgBbc4d3q3v7P99PE+8WJztTqlL6c0sqnqFWAFtS+W93beItaPdzzmaNMfNhEX79bvfrQahWgBZXuVo/eO/47608Cf37k4cfX+UqtfvHoahWgBTX+eOHRu9VTWy4uY2KtljbW1zv1zE7UKsA3UeOvLJ157pQlXv0LNmdW9ZWVTzn0lI2fD/T1UlerAC3wp/bvhNMC0AK1eiecFoAWqNU74bQAtECt3gmnBaAFavVOOC0ALVCrd8JpAWjBuVrtuu719bXaUo7a7XZd133e0sKqWnN4lgCYxblafXp6+vXr1263q7aaPbvd7u+//356empqVa05epYAmMW5Wh3HcbPZdF23nEnXdU9PT+M4NrWq1hw9SwDM4lytAgBF1CoAhFGrABBGrQJAGLUKAGHUKgCEUasAEEatAkAYtQoAYf4DKzngcPTqzpwAAAAASUVORK5CYII=" alt="" />
普通表单
我们需要将表单元素包裹到form-group类里,一般以<div class="form-group">...</div>来进行存放,而在它内容表单元素名称一般放在label标签里,而input标签的类名为
form-control
,值得注意的是,你的checkbox和radio等元素需要写在自己的div里。
例如下面的表单
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" id="exampleInputFile">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
运行之后的效果
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0AAAAE1CAIAAABBcRdOAAAVTElEQVR4nO3dzU7jyMKA4bknbmAuole5jWEdzQX0rlezi8SOXS8Rq+yOBBImOkswEtKEFS2dlrrVpqXkLJI4Zbvs/JAEKjyPRt8HTrliwpF4VRWn/5gCAJCUP976AgAA2IyAAwBIjIADAEiMgAMASIyAAwBITEfADfsnTb3BwyufcTZtf1j/etup4lfU8RAAQNoOH3DNpxBwAAAbWBVw0Qaad9dg0JtVXX84nT6E34TD6uW33gpc/Nxp8Dwn/WHtCtsemh3v9fu9cLbl6NoVhA+Ej7QdBwA4rFcEXKswzpoZtk7AtZ1baagtH+oNHmI/weIH7b7syAkAAAe24RbqrFrmj/SH02Ud9YflA820aYu2dbZQgzHz55qPn383e7aOh6qXuDxQX7oLnqL5E7QdBwA4uFcE3LyHwm+amRNOsmnANc6tDw/WCDseal5VfAWxEqfVa+44DgBwaK95D9ywMSxIpciW5toB13buIQKu+eyrjgMAHNa+Aq4STZX9zdUB13ruq7ZQg59k7f3Q7vfoWYUDAN7Eph8jctIfrrcCFzl77RW41nNfcxNDpdciz1AJwcZTty4oAgAc2t4CLji/N3gIbhNY6z1wLedOw5LqDQZtHyNSfSi+4LbGB5WcRNbtIicAAByUf0oLACAxAg4AIDECDgAgMQIOACAxAg4AIDECDgAgMQIOACAxAg4AIDECDgAgMQIOACAxXQFXFEWe51mWXQMAcBCj0SjP86Iotgm4oihub28fHx+/ffv2PwAADuLbt2+Pj49ZlnU0XGvA5Xn++Pj448ePoiheAAA4iKIofvz48fj4mOf5xgGXZdn3799///49mUzaxgAAsFuTyeT379/fv38fjUZtY1oD7vr6uigK9QYAcGCTyaQoiuvr67YBXQH38vKyn6sCAKDLy8uLgAMASImAAwBIjIADAEiMgAMASIyAAwBIjIADAEjMvgPu7vKfpsu7ra41mPP86jn8AgDgAzlEwL2y1zonF3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AJAYAQcAkBgBBwCQGAEHAJCYroAriiLP8yzLrtM0Go3yPC+K4mCvJgDAAbQGXFEUt7e34/E43QAqiuLp6SnLsnR/BACAptaAy/N8PB4f8lL2ZDwe53n+1lcBALAzrQF3NAtXRVGMRqO3vgoAgJ1pDbjr6+tDXsdeHdPPAgAg4AAAEiPgAAASI+AAABIj4AAAEiPgAAASI+AAABKTcMA9PDysOfL9/ywAAOvbTcAN+ydL/eE6w1ePip/YGzxMp9OHQW/+1ToEHABwTHYQcNUcexj0VtbZ1gFXEnAAwMf1+oArV8WCA/M8q4Za7fhg0Kst2c2qbNBfHh72q0Nmz/VQnrlmBgo4AOCYvD7gOpbcugKufGR5/izMmkOWy222UAEAdvMeuOAtcJWq6lyBGzaGVVIwHFN+LeAAAHZ8F+qi5JY7nm0BF9bXosYqVRaOEXAAAEt7+BiRyo6ngAMA2LFXB1zkjtKwtzbdQhVwAAAr7OgmhiCmgneyhW9qa7tDYTrsn8SqTMABAMTt4YN8G/cxzI8OB71wC3W4+DCQcvwGATfvQR8jAgB8QAn/U1rrO6afBQBAwAEAJEbAAQAkRsABACRGwAEAJEbAAQAkRsABACRGwAEAJKY14LIsK4rikJeyJ0VRjEajt74KAICdaQ24+/v7p6enQ17Knjw9PeV5/tZXAQCwM60BVxTFzc3NeDxOdx2uKIqnp6ebm5tfv3699bUAAOxMa8BNp9OiKO7v77Msu07TaDTK81y9AQBHpivgAAB4hwQcAEBiBBwAQGIEHABAYgQcAEBiBBwAQGIEHABAYgQcAEBi/g/J8FBeot34ZwAAAABJRU5ErkJggg==" alt="" />
水平排放的表单
需要你的表单元素需要水平排放,可以在表单上添加类.form-inline
,这种表单一般在元素比较少时比较适用
例如
<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail3">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword3">Password</label>
<input type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
<button type="submit" class="btn btn-default">Sign in</button>
</form>
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiAAAAA9CAIAAAAbPEUnAAAGtklEQVR4nO3cQW6jOgDG8blTL/DOkcNE7xrdZc0VWGU3EpFKo1kSKkUasqLSq9SqTiXyFgSwwcYJwZDA/6dZpA54HHD8xXbaXycAABz4NXYDAADTRMAAAJwgYAAAThAwAAAnCBgAgBMEDADACQIGAOAEAQMAcIKAAQA4QcAAAJwgYAAATlgCRggRx3EYhhvMwHa7jeNYCEFPmLmWnoDePfqbq6W3tAWMEOL19XW/37+/v/+HGXh/f9/v92EY1voKPWFuTD0BvcvfXEmSPO6lFkIcDgdtb2kLmDiO9/v95+enEOKIGRBCfH5+7vf7OI7pCXNm6gnoXRzHSZKM3YoeJEnS7C1tAROG4cfHx8/PT5ZlLhuGe5Fl2c/Pz8fHx3a7lcvpCXNj6gno3WSmiUKIZm9pC5jNZiOEYEyZlSzLhBCbzUYupCfMkLYnoHdTusLN12IJmOPx6LI9uEfH47EZMPSEGWr2BPRuSleYgIEdAYMcATOAKV1hAgZ2BAxyBMwApnSFCRjYETDIETADmNIVJmBgR8AgR8AMYEpXmICBHQGDXLMn/HuBsVr7oAgYzAsBg5w2YP5p9Sf8PVZrHxQBYxX5z01+dENDT6fIf/aCVH6AgdwQMJqecGM/cCjy77l198AUMC2nEDDXuipg1sunynItFS9Wbzc2pIdKHAaMs3cqATO0GwNG6QmR/3y3t4+AsekpYN5Wi6e628fD7tZLeXAe2+UBo7b7bbW4p5dxOp1GCJg08J69IPCrT7ORX/9kmwae5gMvM5jR9Bkw5x6QFg81MxupuLrRjcI08IpT0sArTtfXrlRTdr+yOxUHBQSMRY8Bo46Eb6vFiBHzoAHTmGFUr0N+qpzkLFYr9YB1GfTaa19WcsnBl76WAQKmeC5/a9cHBuXcyJePJmDG0XvA+FH9qepGy8XlY11hlTCR73me2jmkzF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uY3W6XJEmWZS5bhfuSZVmSJHEcy4X0hBnS9gT0brfbHQ6HsVvRg8Ph0OwtbQEjhHh5efn79+80AhZWQogkSV5eXr6/v2vl9IRZMfUE9C5/cyVJ8rhvLiHE4XDQ9pa2gMnP3O12YRhuMAPb7TaOY+2YQk+YlZaegN49+purpbdYAgYAgG4IGACAEwQMAMAJAgYA4AQBAwBwgoABADhBwAAAnCBgAABOEDAAACcIGACAEwQMAMAJAgYA4AQBAwBwgoABADhBwAAAnPgfCioz9lE7Of4AAAAASUVORK5CYII=" alt="" />
普通表单+元素水平排放
这种表单用的是最多的,在一般用户注册,填写资料时,经常可以见到如下的表单效果
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAxgAAADKCAIAAACpAXGKAAAM3ElEQVR4nO3dS27qSgKA4bunbKDXwWLQ2caZMWYLjJi1BFIcq4fBSEiHjIh0IyVKJRLpAS/bPJJTKV7O9+lKDYXtlHuSX1UO558PAACi/HPuCQAAXCshBQAQSUgBAEQSUgAAkYQUAEAkIQUAEElIAQBEElIAAJGEFABAJCEFABBJSAEARBJSAACRhNRRhBCKosiybAgAXL88z4uiCCHUfuMLqfRCCHd3d5PJ5PHx8V8A4Po9Pj5OJpMsy2otJaTSK4piMpk8Pz+HEN4AgOsXQnh+fp5MJkVRlH/pC6n0six7enp6f3+fz+fnngsAkMB8Pn9/f396esrzvDwupNIbDochBBUFAE0yn89DCMPhsDwopNIbDodvb2/nngUAkNjb25uQOjohBQCNJKROQUgBQCMJqVMQUgDQSELqFIQUADSSkDoFIQUAjSSkTkFIAUAjXXhI9ds321qdcZLLtvv118fy5ZC67/3e1rv/1g+/7/3uDmblFwBAGj8zpLZ/xAWF1De76eDFhRQApHQNIbUznJb90+m0FnXV7n98jMtvyofVC+yiV6R2h9Rs0P3dHQx6m1Wq+159xWo26O5YyLIiBQDHcuUhtVc5krZT6kpDavXZIqEWrxeBNaufe98rHy2kAOAoriGkdsbQ8pN2/2OzEtXurz/Yjq998XRxIbX7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FJVnxkXUgBwfkIqvfgv5NxE1f6vP1gOCykAOD8hld4R4yPJF57/DSEFAAcIqfRSxkflS5/K23wnIqQA4AAhlV7a+Bivv5D8r76SPBEhBQAHCKn0mhQfTboXAEhOSKXXpPho0r0AQHJCKr0mxUeT7gUAkhNS6TUpPpp0LwCQnJBKr0nx0aR7AYDkhFR6WZaFEM49iwRCCHmen3sWAHC5hFR6o9Ho4eHh3LNI4OHhoSiKc88CAC6XkEovhHB7ezudTq93XSqE8PDwcHt7+/r6eu65AMDlElJHEUIYjUZZlg2vU57nRVGoKAA4TEgBAEQSUgAAkYQUAEAkIQUAEElIAQBEElIAAJGEFABAJCEFABBJSAEARBJSAACRhBQAQCQhBQAQSUgBAEQSUgAAkYQUAECk/wMJQ68H4b1L8QAAAABJRU5ErkJggg==" alt="" />
实现这种表单使用了.form-horizontal
类,每行元素被包裹在 <div class="form-group">
...</div>即可
form class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Sign in</button>
</div>
</div>
</form>
我们通过代码也可以看到,在进行表单布局时,也可以用col-sm和col-sm-offset进行栅格布局!