zoukankan      html  css  js  c++  java
  • BootStrap的布局学习

    布局组件无数可复用的组件,包括字体图标、下拉菜单、导航、警告框、弹出框等更多功能。

    Bootstrap的使用非常灵活,可以对各种组件进行合并使用(如:为标签页项 添加带下拉菜单),下面的知识点中将逐个介绍这些组件。

    包括250多个来自 Glyphicon Halflings 的字体图标。Halflings 一般是收费的,但是他们的作者允许 Bootstrap 免费使用。为了表示感谢,希望你在使用时尽量为Halflings 添加一个友情链接。

    如何使用


    出于性能的考虑,所有图标都需要一个基类和对应每个图标的类。把下面的代码放在任何地方都可以正常使用。注意,为了设置正确的内补(padding),务必在图标和文本之间添加一个空格。

    不要和其他组件混合使用

    图标类不能和其它组件直接联合使用。它们不能在同一个元素上与其他类共同存在。应该创建一个嵌套的 标签,并将图标类应用到这个 标签上。

    只对内容为空的元素起作用

    图标类只能应用在不包含任何文本内容或子元素的元素上。

    改变图标字体文件的位置

    Bootstrap 假定所有的图标字体文件全部位于 ../fonts/ 目录内,相对于预编译版 CSS 文件的目录。如果你修改了图标字体文件的位置,那么,你需要通过下面列出的任何一种方式来更新 CSS 文件:

    • 在 Less 源码文件中修改 @icon-font-path 和/或 @icon-font-name 变量。
    • 利用 Less 编译器提供的 相对 URL 地址选项。
    • 修改预编译 CSS 文件中的 url() 地址。 根据你自身的情况选择一种方式即可

    图标的可访问性

    现代的辅助技术能够识别并朗读由 CSS 生成的内容和特定的 Unicode 字符。为了避免 屏幕识读设备抓取非故意的和可能产生混淆的输出内容(尤其是当图标纯粹作为装饰用途时),我们为这些图标设置了 aria-hidden="true" 属性。

    如果你使用图标是为了表达某些含义(不仅仅是为了装饰用),请确保你所要表达的意思能够通过被辅助设备识别,例如,包含额外的内容并通过 .sr-only 类让其在视觉上表现出隐藏的效果。

    如果你所创建的组件不包含任何文本内容(例如, <button> 内只包含了一个图标),你应当提供其他的内容来表示这个控件的意图,这样就能让使用辅助设备的用户知道其作用了。这种情况下,你可以为控件添加 aria-label 属相。

    1. <span class="glyphicon glyphicon-search" aria-hidden="true"></span>

    实例


    可以把它们应用到按钮、工具条中的按钮组、导航或输入框等地方。

    1. <button type="button" class="btn btn-default" aria-label="Left Align">
    2. <span class="glyphicon glyphicon-align-left" aria-hidden="true"></span>
    3. </button>
    4. <button type="button" class="btn btn-default btn-lg">
    5. <span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star
    6. </button>

    alert组件中所包含的图标是用来表示这是一条错误消息的,通过添加额外的.sr-only 文本就可以让辅助设备知道这条提示所要表达的意思了。

    1. <div class="alert alert-danger" role="alert">
    2. <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
    3. <span class="sr-only">Error:</span>
    4. Enter a valid email address
    5. </div>

    完整的代码:

    <!DOCTYPE HTML>
    <html>
    <head>
    <link rel="stylesheet" href="/stylesheets/bootstrap.min.css">
    </head>
    <body>
    <div class="container">
    <div class="btn-toolbar" role="toolbar">
    <div class="btn-group">
    <button type="button" class="btn btn-default" aria-label="Left Align"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span></button>
    <button type="button" class="btn btn-default" aria-label="Center Align"><span class="glyphicon glyphicon-align-center" aria-hidden="true"></span></button>
    <button type="button" class="btn btn-default" aria-label="Right Align"><span class="glyphicon glyphicon-align-right" aria-hidden="true"></span></button>
    <button type="button" class="btn btn-default" aria-label="Justify"><span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span></button>
    </div>
    </div>
    <div class="btn-toolbar" role="toolbar">
    <button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
    <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
    <button type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
    <button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
    </div>
    </div>
    </body>
    </html>

  • 相关阅读:
    Windows 7/8 删除IE临时文件,包括Cookie的批处理
    SQL Server 2005/2008/2008R2/2012 删除登录名的步骤
    NetAdvangate Infragisticss 控件在工程移动到别的机器上,引用失效问题
    如果一个主板有多个BIOS更新包,则只需要更新最新的包即可。
    Intel存储技术软件的兼容性问题,造成磁盘IO不稳,卡死系统
    汤姆大叔JavaCript系列4阅读笔记
    IDL(接口描述语言)
    document.defaultView.getComputedStyle() 的使用
    汤姆大叔JavaCript系列1阅读笔记
    汤姆大叔JavaCript系列10阅读笔记
  • 原文地址:https://www.cnblogs.com/airycode/p/5150282.html
Copyright © 2011-2022 走看看