使用BootStrap布局网站首页
需求分析
请使用BootStrap对我们的首页进行优化
步骤分析
- 新建一个HTML页面.引入bootStrap相关的js和CSS
- 定义一个整体的div, 将整体的div分成8个部分
- 完成没部分的内容显示
代码实现
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<!--
准备工作:
<meta name='viewport'>
1.导入bootstrap css文件
2.导入JQuery
3.bootstrap.js
4.写一个div class = container 支持响应式的布局容器
-->
<link rel="stylesheet" href="../css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--
jQuery文件。务必在bootstrap.min.js 之前引入
-->
<script src="../js/jquery-1.11.0.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="../js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4">
<img src="../img/logo2.png" />
</div>
<div class="col-md-4 hidden-xs">
<img src="../img/header.png" />
</div>
<div class="col-md-4">
<a href="#">登录</a>
<a href="#">注册</a>
<a href="#">购物车</a>
</div>
</div>
<!--菜单-->
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-inverse" role="navigation">
<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">
<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="#">手机数码</a>
</li>
<li>
<a href="#">鞋靴箱包</a>
</li>
<li>
<a href="#">电脑办公</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">所有分类 <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#">手机数码</a>
</li>
<li>
<a href="#">鞋靴箱包</a>
</li>
<li>
<a href="#">电脑办公</a>
</li>
<li class="divider"></li>
<li>
<a href="#">Separated link</a>
</li>
<li 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="请输入要搜索的商品">
</div>
<button type="submit" class="btn btn-default">搜索</button>
</form>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</div>
</div>
<div>
<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="../img/1.jpg" alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="../img/2.jpg" alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="../img/3.jpg" 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"></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"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<!--最新商品这里-->
<div class="row">
<div class="col-md-12">
<h3>最新商品<img src="../images/title2.jpg"/></h3>
</div>
</div>
<!--商品部分 -->
<div class="row">
<!--左边div-->
<div class="col-md-2 hidden-sm hidden-xs">
<img src="../products/hao/big01.jpg" width="100%" height="100%" />
</div>
<!--右边div-->
<div class="col-md-10">
<!--上面部分-->
<div class="row">
<!--中等广告图-->
<div class="col-md-6">
<img src="../products/hao/middle01.jpg" width="100%" />
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
</div>
<!--下面部分-->
<div class="row">
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<img src="../products/hao/ad.jpg" width="100%" />
</div>
</div>
<!--最新商品这里-->
<div class="row">
<div class="col-md-12">
<h3>最新商品<img src="../images/title2.jpg"/></h3>
</div>
</div>
<!--商品部分 -->
<div class="row">
<!--左边div-->
<div class="col-md-2 hidden-sm hidden-xs">
<img src="../products/hao/big01.jpg" width="100%" height="100%" />
</div>
<!--右边div-->
<div class="col-md-10">
<!--上面部分-->
<div class="row">
<!--中等广告图-->
<div class="col-md-6">
<img src="../products/hao/middle01.jpg" width="100%" />
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
</div>
<!--下面部分-->
<div class="row">
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
<!--商品项-->
<div class="col-md-2 col-xs-4" style="text-align: center;">
<img src="../products/hao/small01.jpg" />
<p>豆浆机</p>
<p>$998</p>
</div>
</div>
</div>
</div>
<!--页脚广告-->
<div>
<img src="../image/footer.jpg" width="100%" />
</div>
<!--网站声明-->
<div style="text-align: center;">
<a href="http://www.itheima.com">关于我们</a>
<a href="http://www.itheima.com">联系我们</a>
<a href="http://www.itheima.com">招贤纳士</a>
<a href="http://www.itheima.com">法律声明</a>
<a href="http://www.itheima.com">友情链接</a>
<a href="http://www.itheima.com">支付方式</a>
<a href="http://www.itheima.com">配送方式</a>
<a href="http://www.itheima.com">服务声明</a>
<a href="http://www.itheima.com">广告声明</a>
<br />
Copyright © 2005-2016 传智商城 版权所有
</div>
</div>
</body>
</html>