黑马程序员技术交流社区
标题:
[石家庄校区]web-BootStrap
[打印本页]
作者:
Black_Y
时间:
2018-5-3 15:45
标题:
[石家庄校区]web-BootStrap
web-BootStrap
#BootStrap
##BootStrap(CSS和JS的框架)响应式框架
##BootStrap的引入
###步骤一
```html
添加meta标签:
<meta name="viewport"content="width=device-width,intial-scale=1">
```
###步骤二
引入BootStrap的css文件
###步骤三
引入jQuery的js文件(一定要先引入,依赖 性)
###步骤四
引入BootStrap的js文件
##BootStrap的栅格系统
BootStrap的栅格系统(每行最大12列,可嵌套,偏移)(常用)
###BootStrap可以实现响应式页面:
根据设备的尺寸大小自动调整布局,保证了在各种设备上都能得到很好的展示
### 栅格系统
Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列。它包含了易于使用的预定义类,还有强大的mixin 用于生成更具语义的布局。
使用.row样式定义栅格的行.
定义列:.col-lg-n .col-md-n .col-sm-n .col-xs-n
##使用bootstrap实现商城首页响应式页面
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- 根据设备宽度,调整缩放比例 -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>网站首页</title>
<!-- 引入BootStrap的CSS -->
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/bootstrap-theme.min.css" />
<!-- 引入JS-->
<script type="text/javascript" src="../js/jquery-1.11.3.min.js" ></script>
<script type="text/javascript" src="../js/bootstrap.min.js" ></script>
</head>
<body>
<!--整体div-->
<div class="container">
<!--Logon部分DIV-->
<div class="row">
<div class="col-md-4">
<img src="../img/logo2.png" />
</div>
<div class="col-md-4">
<img src="../img/header.png" />
</div>
<div class="col-md-4">
<a href="">登录</a>
<a href="">注册</a>
<a href="">购物车</a>
</div>
</div>
<!--导航条部分DIV-->
<div class="row">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">首页</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">手机数码 <span class="sr-only">(current)</span></a></li>
<li><a href="#">电脑办公</a></li>
<li><a href="#">电脑办公</a></li>
<li><a href="#">电脑办公</a></li>
<li><a href="#">电脑办公</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">更多 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div>
<!--图片轮播部分DIV-->
<div class="row">
<!-- 图片的小点儿 -->
<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>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
</ol>
<!-- 图片-->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="../img/bartlesvillecf.jpg" >
<div class="carousel-caption">
</div>
</div>
<div class="item">
<img src="../img/okwu-athletics.jpg">
<div class="carousel-caption">
</div>
</div>
<div class="item">
<img src="../img/okwu.jpg">
<div class="carousel-caption">
</div>
</div>
<div class="item">
<img src="../img/emancipation.jpg">
<div class="carousel-caption">
</div>
</div>
</div>
<!-- 图片左右选择 -->
<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>
<!--最新商品部分DIV-->
<div class="row">
<div >
<h3>最新商品<img src="../img/title2.jpg"></h3>
</div>
<div >
<div class="col-md-2" style="padding: 0px;height: 440px;">
<img src="../img/big01.jpg" width="100%" height="100%"/>
</div>
<div class="col-md-10">
<!--第一行-->
<div class="row" >
<div class="col-md-6" style="height:230px;padding: 0px;">
<img src="../img/middle01.jpg" height="100%" width="100%"/>
</div>
<div class="col-md-2">
<img src="../img/small01.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small02.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small03.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
</div>
<!--第一行-->
<div class="row">
<div class="col-md-2">
<img src="../img/small01.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small02.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small03.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small01.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small02.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small03.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
</div>
</div>
</div>
</div>
<!--广告部分DIV-->
<div class="row">
<img src="../img/ad.jpg" width="100%"/>
</div>
<!--热门商品部分DIV-->
<div class="row">
<div >
<h3>热门商品<img src="../img/title2.jpg"></h3>
</div>
<div >
<div class="col-md-2" style="padding: 0px;height: 440px;">
<img src="../img/big01.jpg" width="100%" height="100%"/>
</div>
<div class="col-md-10">
<!--第一行-->
<div class="row" >
<div class="col-md-6" style="height:230px;padding: 0px;">
<img src="../img/middle01.jpg" height="100%" width="100%"/>
</div>
<div class="col-md-2">
<img src="../img/small01.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small02.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small03.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
</div>
<!--第一行-->
<div class="row">
<div class="col-md-2">
<img src="../img/small01.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small02.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small03.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small01.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small02.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
<div class="col-md-2">
<img src="../img/small03.jpg" />
<center><p>豆浆机</p>
<p style="color:red">¥299</p></center>
</div>
</div>
</div>
</div>
</div>
<!--footer部分DIV-->
<div class="row">
<img src="../img/footer.jpg" width="100%"/>
</div>
<!--链接及关于我们部分DIV-->
<div class="row">
<center>
关于我们 联系我们 招贤纳士 法律声明 友情链接 支付方式 配送方式 服务声明 广告声明 <br/>
Copyright © 2005-2016 传智商城 版权所有
</center>
</div>
</div>
</body>
</html>
```
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2