3. 表单(Forms).Bootstrap的表单是非常惊艳的部分。最好的地方在于你如何使用这些hmtl标签,它都会有很好的表现效果,而且不需要其他多余的代码。无论多复杂的布局都可以根据这些简洁,可扩展,事件绑定的要素来轻易实现。主要提供了四四种表单选项,如表2-2所示: 名字
Class
描述
Vertical (default) .form-vertical (not required) 堆放式, 可控制的左对齐标签 Inline Search Horizontal
.form-inline .form-search .form-horizontal
左对齐标签和简约的内联控制块 放大的圆角,具有美感的搜索框 左漂浮, 右对齐标签
推荐到官方文档去体验下各种表单要素的真实效果,在chrome,Firefox等现代浏览器下显示十分优雅。同时可以使用.control-group来控制表单输入、错误等状态,需要wekit内核。如图2-5所示:
图2-5 表单状态控制
代码片段如下:
View Code
4.按钮(Buttons).Bootstrap提供多种样式的按钮,同样是通过CSS的类来控制,包括btn, btn-primary, btn-info,btn-success等不同颜色的按钮,亦可以简单通过.btn-large .btn-mini等CSS的class控制按钮大小,能够同时用在,
图2-6 按钮(Buttons)
代码片段如下: View Code
btn
Standard gray button with gradient
btn btn-primary
Provides extra visual weight and identifies the primary action in a set of buttons
btn btn-info
Used as an alternative to the default styles
btn btn-success
Indicates a successful or positive action
btn btn-warning
Indicates caution should be taken with this action
btn btn-danger
Indicates a dangerous or potentially negative action
btn btn-inverse
Alternate dark gray button, not tied to a semantic action or use
如果需要更多样式的按钮,可以在这个网站来定制。 如果需要更多的整个网站的样式和风格,可以在这个和那个网站来定制。 参考文献与延伸阅读
1. M. Pilgrim, HTML5: up and running: Oreilly & Associates Inc, 2010
2. HTML 5
4. 基于wordpress的Bootstrap http://bootstrapwp.rachelbaker.me/
5.Why did Twitter release Bootstrap? http://www.quora.com/Why-did-Twitter-release-Bootstrap
BootStrap入门教程 (三)
上讲回顾:Bootstrap的基础CSS(Base CSS)提供了优雅,一致的多种基础Html页面要素,包括排版,表格,表单,按钮等,能够满足前端工程师的基本要素需求。
Bootstrap作为完整的前端工具集,内建了大量的强大优雅可重用的组件,包括按钮(Button),导航(Navigation),标签(Labels),徽章(Badges),排版(Typography),缩略图( thumbnails),提醒(Alert),进度条(progress bar),杂项(Miscellaneous)。本讲将深入讲解这些内容。
1. 按钮(Button)
上讲最后提及到button的多种简单样式,然而在bootstrap中可以通过组合button,从而获得更多类似于工具条的功能,组件中的按钮可以组合成按钮组(button group)和按钮式下拉菜单(button drown menu). (下一讲的Javascript Plugin会提及到更多的按钮的应用). 1.1 按钮组(button group)
按钮组顾名思义是将多个按钮集合成一个页面部件。只需要使用btn-group类和一系列的或者
? 建议在单一的按钮组中不要混合使用和
? 使用图标的时候要确保正确的引用位置
按钮组和按钮工具条都非常容易实现,如图3-1所示: