Python-bootstrap
1 引入
如果想要用到BootStrap提供的js插件,那么还需要引入jQuery框架,因为BootStrap提供的js插件是依赖于jQuery的
<link type="text/css" rel="stylesheet" href="../css/bootstrap.css">
<script type="text/javascript" src="../bootstrap.js"></script>
<script type="text/javascript" src="../jquery-1.12.4.min.js"></script>
2 容器
- 固定宽度:.container
- 流式布局:.container-fluid
3 响应式布局
- 超小屏幕:小于 768px
- 小屏幕:大于等于 768px
- 中等屏幕:大于等于 992px
- 大屏幕:大于等于 1200px
为什么要进行响应式开发?
随着移动设备的流行,网页设计必须要考虑到移动端的设计。同一个网站为了兼容PC端和移动端显示,就需要进行响应式开发。
什么是响应式?
利用媒体查询,让同一个网站兼容不同的终端(PC端、移动端)呈现不同的页面布局。
用到的技术:
CSS3@media查询
用于查询设备是否符合某一特定条件,这些特定条件包括屏幕尺寸、是否可触摸、屏幕精度、横屏竖屏等信息。
常见属性:
- device-width, device-height 屏幕宽、高
- width,height 渲染窗口宽、高
- orientation 设备方向
- resolution 设备分辨率
语法:
@media mediatype and|not|only (media feature) {
CSS-Code;
}
不同的媒体使用不同的stylesheet
<link rel="stylesheet" media="mediatype and|not|only (media feature)" href="mystylesheet.css">
viewport
手机浏览器是把页面放在一个虚拟的"窗口"(viewport)中,通常这个虚拟的"窗口"(viewport)比屏幕宽,这样就不用把每个网页挤到很小的窗口中(这样会破坏没有针对手机浏览器优化的网页的布局),用户可以通过平移和缩放来看网页的不同部分。
设置viewport
一个常用的针对移动网页优化过的页面的 viewport meta 标签大致如下:
<meta name=”viewport” content=”width=device-width, initial-scale=1, maximum-scale=1″>
- width:控制 viewport 的大小,可以指定的一个值,如果 600,或者特殊的值,如 device-width 为设备的宽度(单位为缩放为 100% 时的 CSS 的像素)。
- height:和 width 相对应,指定高度。
- initial-scale:初始缩放比例,也即是当页面第一次 load 的时候缩放比例。
- maximum-scale:允许用户缩放到的最大比例。
- minimum-scale:允许用户缩放到的最小比例。
- user-scalable:用户是否可以手动缩放。
Bootstrap的栅格系统
- container
- row
- column
注意事项: 使用Bootstrap的时候不要让自己的名字与Bootstrap的类名冲突。
4 栅格系统
1、概念
将父级可用宽度(content)均分为12等份
0. 包含在container里面
1. 每一行(row)均分成12列(col-xx-**)必须放在row中),
2. 每一个标签可以自定义占的列数(col-xx-**)
列偏移
列排序
2、列比
- 超小屏幕:.col-xs-*
- 小屏幕:.col-sm-*
- 中等屏幕:.col-md-*
- 大屏幕:.col-lg-*
v-hint:只设置小屏列比会影响大屏列比;只设置大屏列比小屏时会撑满屏幕
3、行
<div class="row"></div>
...
<div class="row"></div>
4、列偏移
- 超小屏幕:.col-xs-offset-*
- 小屏幕:.col-sm-offset-*
- 中等屏幕:.col-md-offset-*
- 大屏幕:.col-lg-offset-*
5 常用组件
字体图标
优点:
size小
放大不失真
可以随字体颜色变化而变化
1. Bootstrap自带的
<span class='glyphicon glyphicon-heart'></span>
2. font Awesome
<i class="fa fa-heart"></i>
http://www.fontawesome.com.cn/
下拉菜单
按钮组
输入框俎
导航
分页
标签和徽章
页头
缩率图
进度条
补充:滚动的进度条
var $d1 = $("#d1");
var width = 0;
var theID = setInterval(setValue, 200);
function setValue() {
if (width === 100) {
clearInterval(theID);
} else {
width++;
$d1.css("width", width+"%").text(width+"%");
}
}
6. Bootstrap常用组件
7. Bootstrap常用插件
1. 模态框
模态框的HTML代码放置的位置
务必将模态框的HTML代码放在文档的最高层级内(也就是说,尽量作为 body 标签的直接子元素),以避免其他组件影响模态框的展现和/或功能。
<!-- 触发模态框的按钮 -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button> <!-- 模态框 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
注意:
- 通过为模态框设置
.bs-example-modal-lg
和.bs-example-modal-sm
来控制模态框的大小。 - 通过
.fade
类来控制模态框弹出时的动画效果(淡入淡出效果)。 - 通过在
.modal-body
div中设置.row
可以使用Bootstrap的栅格系统。
2. 轮播图
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol> <!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="..." alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="..." alt="...">
<div class="carousel-caption">
...
</div>
</div>
...
</div> <!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
可以在为图片添加介绍信息:

<div class="item">
<img src="..." alt="...">
<div class="carousel-caption">
<h3>...</h3>
<p>...</p>
</div>
</div>

方法:
设置切换间隔为2秒,默认是5秒。
$('.carousel').carousel({
interval: 2000
})
8. 其他插件
1. SweetAlert for bootstrap
https://lipis.github.io/bootstrap-sweetalert/
REFERENCE-LIWENZHOU :http://www.cnblogs.com/liwenzhou/p/8214637.html
Python-bootstrap的更多相关文章
- ez_setup.py(安装python下setuptools用)
#!python"""Bootstrap setuptools installation If you want to use setuptools in your pa ...
- selenium python 环境搭建(64位 windows)
之前写了同样的文章,可是后来自己按照给文章再次搭建环境当搭建环境成功后却发现还是无法用.使用from selenium import webdriver,在run的时候却出现ImportError: ...
- boost.python编译及演示样例
欢迎转载,转载请注明原文地址:http://blog.csdn.net/majianfei1023/article/details/46781581 linux编译boost的链接:http://bl ...
- Python - excel 详解
安装 pip install xlrd # 读xlspip install xlwt # 写xlspip install xlutils # 改写xls 读取 Excel ...
- Python打包上传
你可以用pip导出你的dependency: $ pip freeze > requirements.txt 然后在通过以下命令安装dependency: pip install -r requ ...
- python pip ez_setup.py
#!/usr/bin/env python """Bootstrap setuptools installation To use setuptools in your ...
- 用Buildout来构建Python项目
用Buildout来构建Python项目 什么是Buildout (Remixed by Matt Hamilton, original from http://xkcd.com/303) Bui ...
- Ninja - chromium核心构建工具
转自:http://guiquanz.me/2014/07/28/a_intro_to_Ninja/ Ninja - chromium核心构建工具Jul 28, 2014 [在线编辑] 缘由 经过上次 ...
- 使用buildbot实现持续集成(转载)
转载自:http://www.oschina.net/p/buildbot 使用 Buildot 实现持续集成 使用基于 Python 的工具实现持续集成的理论与实践 牛仔式编码的日子在大多数组织中早 ...
- [置顶] 教你如何搭建RobotFramework环境
看到这篇文章的朋友,相信已经知道RobotFramework是干什么的了,我这里就不再赘述了. 搭建步骤: 1. 下载安装Python,下载地址http://www.python.org/getit/ ...
随机推荐
- 自动清理MySQL binlog日志
开启MySQL binlog日志的服务器,如果不设置自动清理日志,默认binlog日志一直保留着,时间一长,服务器磁盘空间被binlog日志占满,导致MySQL数据库出错. 使用下面方法可以安全清理b ...
- 让maven项目使用nexus作为远程仓库
让maven项目使用nexus作为远程仓库有两种方式,第一种是在项目的pom.xml中进行更改,让单个项目使用nexus仓库:另一种是通过修改maven的配置文件settings.xml进行更改,让所 ...
- 20190312 Windows上Kafka集群
1. 复制config/server.properties为server1.properties和server2.properties 2. 以server1.properties为例,修改配置 br ...
- JDBC中的那些设计模式
一.单例模式获取数据库连接 1.关于单例模式的定义 保证一个类仅有一个实例,并提供访问它的全局访问点.Java里面实现的单例是一个虚拟机的范围.因为装载类的功能时虚拟机,所以一个虚拟机在听过自己的Cl ...
- linux下编译出现tmp空间不足解决办法
编译的时候出现问题: fatal error: error writing to /tmp/ccHqgMoi.s: No space left on device 原因 : 系统 /tmp/空间不足, ...
- <!--more-->搭建的博客设置主页内容高度
用 markdown写文章时插入<!--more-->,文章会自动从插入的位置截断,也就是说在博客中只显示<!--more-->之前的内容,点击阅读全文之后会显示所有内容.
- Linux记录-Linux Swap分区虚拟内存相关解决方案
Swap用途:Swap意思是交换分区,通常我们说的虚拟内存,是从硬盘中划分出的一个分区.当物理内存不够用的时候,内核就会释放缓存区(buffers/cache)里一些长时间不用的程序,然后将这些程序临 ...
- Log4net(一)-——配置文件
一.Log4Net框架介绍 Log4net 是 Apache 下一个开放源码的项目,它是Log4j 的一个克隆版.Log4net中定义了多种日志信息输出模式.它可以根据需要将日志输出到控制台,文本文件 ...
- 浅谈分词算法(5)基于字的分词方法(bi-LSTM)
目录 前言 目录 循环神经网络 基于LSTM的分词 Embedding 数据预处理 模型 如何添加用户词典 前言 很早便规划的浅谈分词算法,总共分为了五个部分,想聊聊自己在各种场景中使用到的分词方法做 ...
- 如何写一个好的缺陷(Defect)报告
编写缺陷报告是测试人员的日常工作,好的缺陷报告能够让开发人员更容易理解,更快速的定位问题:不好的缺陷报告可能会误导调查方向,增加沟通成本.那么一个好的缺陷报告应该包括哪些方面呢? 请看我的mindma ...