Bootstrap笔记

Bootstrap will figure out how wide your screen is and respond by resizing your HTML elements - hence the name Responsive Design.
With responsive design, there is no need to design a mobile version of your website. It will look good on devices with screens of any width.

Bootstrap将会根据你的屏幕的大小来调整HTML元素的大小 —— 强调 响应式设计的概念。

通过响应式设计,你无需再为你的网站设计一个手机版的。它在任何尺寸的屏幕上看起来都会不错。

引入 BootStrap

<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.min.css"/>

适配图片

通过Bootstrap,我们要做的只是给图片添加 img-responsive class属性。这样图片的宽度就能完美地适配你的页面的宽度了。

![](/images/running-cat.jpg)

适配文本

使用Bootstrap,使文本居中,使它看起来更棒。 我们所要做的只是把text-center class属性添加给 h2 元素。

<h2 class="red-text text-center">your text</h2>

适配按钮

通常情况下,你的 button 元素仅与它所包含的文本一样宽。通过使其成为块级元素,你的按钮将会伸展并填满页面整个水平空间,任何在它之下的元素都会跟着浮动至该区块的下一行。

<button class="btn btn-block">Like</button>

添加Bootstrap的 btn-primary class 属性到按钮标签上,使按钮高亮。

<button class="btn btn-block btn-primary">Like</button>

Bootstrap自带了一些预定义的按钮颜色。浅蓝色 btn-info 被用在那些用户可能会采取的操作上。

<button class="btn btn-block btn-info">Info</button>

红色btn-danger被用来提醒用户该操作具有“破坏性”

<button class="btn btn-block btn-danger">Delete</button>

适配网格布局

class row 行
class col-md-* (中等屏幕适配),col-xs-*(小屏适配)

  • 填数字
<div class="row">
    <div class="col-xs-4">
      <button class="btn btn-block btn-primary">Like</button>
    </div>
    <div class="col-xs-4">
      <button class="btn btn-block btn-info">Info</button>
    </div>
    <div class="col-xs-4">
      <button class="btn btn-block btn-danger">Delete</button>
    </div>
  </div>

Font Awesome

Font Awesome 是一个非常方便的图标库。这些图标都是矢量图形,被保存在 .svg 的文件格式中。这些图标就和字体一样,你可以通过像素单位指定它们的大小,它们将会继承其父HTML元素的字体大小。

引入

<link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.2.0/css/font-awesome.min.css"/>

给按钮添加一个icon

<div class="col-xs-4">
      <button class="btn btn-block btn-primary">Like<i class="fa fa-thumbs-up"></i></button>
    </div>
Paste_Image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • FreeCodeCamp - Responsive Design with Bootstrap Use Respo...
    付林恒阅读 2,691评论 0 8
  • CSS全局样式 概览 移动设备优先 布局容器 1、container类用于固定宽度并支持响应式布局的容器 2、co...
    VEN_64d6阅读 1,440评论 0 1
  • (1)####Bootstrap它将会根据你的屏幕的大小来调整HTML元素的大小 —— 强调 响应式设计的概念。 ...
    越IT阅读 1,771评论 0 4
  • 黎明, 太阳羞涩地躲在云后 红着脸 瞪着这个世界 晨雾, 将时间蒙上了面纱 忘记了 你我遇见的精彩瞬间 渐渐地 世...
    石石头阅读 173评论 1 1
  • 当你有意读完这篇文章的时候,说明你已经知道YouCompleteMe的神奇了。我的系统是Ubuntu,语言是Pyt...
    简讯Alfred阅读 1,994评论 2 3