第四章之BootStrap表单与图片_Javascript教程-查字典教程网
第四章之BootStrap表单与图片
第四章之BootStrap表单与图片
发布时间:2016-12-30 来源:查字典编辑
摘要:Bootstrap,来自Twitter,是目前最受欢迎的前端框架。Bootstrap是基于HTML、CSS、JAVASCRIPT的,它简洁灵...

Bootstrap,来自 Twitter,是目前最受欢迎的前端框架。Bootstrap 是基于 HTML、CSS、JAVASCRIPT 的,它简洁灵活,使得 Web 开发更加快捷。

学习要点:

1.表单

2.图片

本节课我们主要学习一下 Bootstrap 表单和图片功能,通过内置的 CSS 定义,显示各种丰富的效果。

一.表单

Bootstrap 提供了一些丰富的表单样式供开发者使用。

1.基本格式

//实现基本的表单样式 <form> <div> <label>电子邮件</label> <input type="email" placeholder="请输入您的电子邮件"> </div> <div> <label>密码</label> <input type="password" placeholder="请输入您的密码"> </div> </form>

注:只有正确设置了输入框的 type 类型,才能被赋予正确的样式。支持的输入框控件包括:text、password、datetime、datetime-local、date、month、time、week、number、email、url、search、tel 和 color。

2.内联表单

//让表单左对齐浮动,并表现为 inline-block 内联块结构 <form>

注:当小于 768px,会恢复独占样式

3.表单合组

//前后增加片段 <div> <div>¥</div> <input type="text"> <div>.00</div> </div>

4.水平排列

//让表单内的元素保持水平排列 <form> <div> <label>电子邮件</label> <div> <input type="email" placeholder="请输入您的电子邮件"> </div> </div> </form>

注:这里用到了 col-sm 栅格系统,后面章节会重点讲解,而 control-label 表示和父元素样式同步。

5.复选框和单选框

//设置复选框,在一行 <div> <label> <input type="checkbox">体育 </label> </div> <div> <label> <input type="checkbox">音乐 </label> </div> //设置禁用的复选框 <div> <label> <input type="checkbox" disabled>音乐 </label> </div> //设置内联一行显示的复选框 <label> <input type="checkbox">体育</label> <label> <input type="checkbox" disabled>音乐</label> //设置单选框 <div> <label> <input type="radio" name="sex" disabled>男</label> </div>

6.下拉列表

//设置下拉列表 <select> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select>

7.校验状态

//设置为错误状态 <div>

注:还有其他状态如下:

样式说明 has-error错误状态 has-success成功状态 has-warning警告状态 //label 标签同步相应状态 <label>Input with success</label>

8.添加额外的图标

//文本框右侧内置文本图标 <div> <label>电子邮件</label> <input type="email"> <span></span> </div>

注:除了 glyphicon-ok 外,还有几个如下表:

样式说明 glyphicon-ok成功状态 glyphicon-warning-sign警告状态 glyphicon-remove错误状态

9.控制尺寸

//从大到小 <input type="password"> <input type="password"> <input type="password">

注:也可以设置父元素 form-group-lg、form-group-sm,来调整。

二.图片

Bootstrap 提供了一些丰富的图片样式供开发者使用。

1.图片形状

//三种形状 <img src="img/pic.png" alt="图片"> <img src="img/pic.png" alt="图片"> <img src="img/pic.png" alt="图片"> //响应式图片 <img src="img/pic.png" alt="图片">

以上所述是小编给大家介绍的Bootstrap表单与图片的相关内容,希望对大家有所帮助!

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类