Bootstrap 垂直(默认)表单

在建立asp.net mvc视图中,默认的表单是垂直表单,与vs 自动创建的T4模板是水平表单,相比较,没有了<div class="form-horizontal"> 和 class=control-label ,也没有列布局项 比如col-md-2 <div class="col-md-10">了。但<class="form-control">仍然保留。

如下视图代码表示了一个垂直表单。

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.CategoryID)
@Html.DropDownList("CategoryID", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.CategoryID, "", new { @class = "text-danger" })
</div>

<div class="form-group">
@Html.LabelFor(model => model.Title)
@Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })

</div>

<div class="form-group">
@Html.LabelFor(model => model.Content)
@Html.EditorFor(model => model.Content)
</div>

<div class="form-group">
@Html.LabelFor(model => model.AuthorName)
@Html.EditorFor(model => model.AuthorName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.AuthorName, "", new { @class = "text-danger" })

</div>

<div class="form-group">
@Html.LabelFor(model => model.PostTime)
@Html.EditorFor(model => model.PostTime, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.PostTime, "", new { @class = "text-danger" })

</div>

<input type="submit" value="新建" class="btn btn-default" />
}

更一般的原始html标记为:

<form class="form-horizontal" role="form">
   <div class="form-group">
      <label for="firstname" class="col-sm-2 control-label">名字</label>
      <div class="col-sm-10">
         <input type="text" class="form-control" id="firstname"
            placeholder="请输入名字">
      </div>
   </div>
   <div class="form-group">
      <label for="lastname" class="col-sm-2 control-label">姓</label>
      <div class="col-sm-10">
         <input type="text" class="form-control" id="lastname"
            placeholder="请输入姓">
      </div>
   </div>
   <div class="form-group">
      <div class="col-sm-offset-2 col-sm-10">
         <div class="checkbox">
            <label>
               <input type="checkbox"> 请记住我
            </label>
         </div>
      </div>
   </div>
   <div class="form-group">
      <div class="col-sm-offset-2 col-sm-10">
         <button type="submit" class="btn btn-default">登录</button>
      </div>
   </div>
</form>

</body>
</html>
时间: 2024-12-12 23:36:15

Bootstrap 垂直(默认)表单的相关文章

Bootstrap中默认表单的创建

<form action=""> <div class="form-group"> <label class="control-label" for="uname">用户名:</label> <input class="form-control" id="uname" type="text"> <spa

Bootstrap&lt;基础六&gt; 表单

Bootstrap 通过一些简单的 HTML 标签和扩展的类即可创建出不同样式的表单. 表单布局 Bootstrap 提供了下列类型的表单布局: 垂直表单(默认) 内联表单 水平表单 垂直或基本表单 基本的表单结构是 Bootstrap 自带的,个别的表单控件自动接收一些全局样式.下面列出了创建基本表单的步骤: 向父 <form> 元素添加 role="form". 把标签和控件放在一个带有 class .form-group 的 <div> 中.这是获取最佳间

SpringSecurity 默认表单登录页展示流程源码

SpringSecurity 默认表单登录页展示流程源码 本篇主要讲解 SpringSecurity提供的默认表单登录页 它是如何展示的的流程, 涉及 1.FilterSecurityInterceptor, 2.ExceptionTranslationFilter , 3.DefaultLoginPageGeneratingFilter 过滤器, 并且简单介绍了 AccessDecisionManager 投票机制 ?1.准备工作(体验SpringSecurity默认表单认证) ??1.1 创

【从零开始学BPM,Day2】默认表单开发

[课程主题]主题:5天,一起从零开始学习BPM [课程形式]1.为期5天的短任务学习2.每天观看一个视频,视频学习时间自由安排. [第二天课程] Step 1 软件下载:H3 BPM10.0全开放免费下载:http://bbs.h3bpm.com/read.php?tid=861&fid=11 Step 2 安装资料:参考本博的"安装资料"分类 Step 3 产品在线帮助浏览:http://bbs.h3bpm.com/read.php?tid=286&fid=11 St

bootstrap 列表 表格 表单

一.列表 ul li 二.表格 table  (http://www.runoob.com/bootstrap/bootstrap-tables.html) 1. 基本表格 <table class="table"> 2. 响应式表格 <div class="table respoinsive"><talbe > 单独设立标题样式 标头样式 三.表单 第一种:常规样式(垂直) <form role="form&qu

BootStrap学习之表单

本文和大家分享的主要是BootStrap的表单相关内容,一起来看看吧,希望对大家学习BootStrap有所帮助. 单独的表单控件会被自动赋予一些全局样式.所有设置了 .form-control 类的 <input> . <textarea> 和 <select>元素都将被默认设置宽度属性为 width: 100% ;. 将 label 元素和前面提到的控件包裹在 .form-group 中可以获得最好的排列. 基本实例: <div class='container

开发bootstrap的from表单事例

<html lang="en"> <head> <title>form</title> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width

jquery配合Bootstrap中的表单验证插件bootstrapValidator使用方法

使用bootstrap遇到表单校验,最常用的一款表单校验插件 github地址:https://github.com/nghuuphuoc/bootstrapvalidator 使用: 将文件下载 或者用 git clone下来 1.引入css到head中,引入js到body结束标签的前面即可 提示: 默认是英语的,需要变成中文: 将github中dist中的\js\language\zh_CN.js 引入文件中即可 官方完整实例版: <!DOCTYPE html> <html>

Bootstrap学习(2)--表单

Bootstrap里的role属性,增强标签的语义化,提高识别力,  如:<form role="form"> input.select.textarea等元素,在Bootstrap框架中,通过定制了一个类名`form-control`,也就是说,如果这几个元素使用了类名“form-control”,将会实现一些设计上的定制效果. 1.宽度变成了100% 2.设置了一个浅灰色(#ccc)的边框 3.具有4px的圆角 4.设置阴影效果,并且元素得到焦点之时,阴影和边框效果会有

Bootstrap系列 -- 14. 表单控件输入框input

每一个表单都是由表单控件组成.离开了控件,表单就失去了意义.接下来的我们简单的来了解Bootstrap框架中表单控件的相关知识. 单行输入框,常见的文本输入框,也就是input的type属性值为text.在Bootstrap中使用input时也必须添加type类型,如果没有指定type类型,将无法得到正确的样式,因为Bootstrap框架都是通过input[type=“?”](其中?号代表type类型,比如说text类型,对应的是input[type=“text”])的形式来定义样式的. <fo