bootstrap布局完成热卖商品模板任务3
首先来看看效果图喜欢拿去:
这些所有的布局都是由bootstrap提供使用栅格布局:
1. 最外层<div>标签自定义类名.hot,用于批量设置其子元素的样式。
2. 在最外层<div>下添加<div>标签并使用类.container实现整体布局,在div.container添加栅格系统,三个<div>分别使用类名.col-md-4,分别在三个<div>中添加商品的图片和商品信息,Bootstrap会在小屏幕时自动变为每行一个商品。
3. 为了按钮宽度和图片宽度一致,这里使用的是自定义的按钮,另外在商品信息中的“ ”图标使用了Bootstrap的字体图标(glyphicon glyphicon-thumbs-up),Bootstrap提供的字体图标和之前介绍过的字体图标使用方式相似,只需要添加相应的类名即可,具体图标对应类名可以查看相关手册。
4. 设置body、h3、h6元素的字体为微软雅黑。
栅格参数
通过下表可以详细查看 Bootstrap 的栅格系统是如何在多种屏幕设备上工作的。
详细的请看看bootstrap的官网官方文档:https://v3.bootcss.com/
下面来看看具体的实现 代码:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询(media queries)功能 -->
<!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 -->
<!--[if lt IE 9]>
<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->
<style>
img {
width: 100%;
height: 300px;
}
.btn-block {
text-align: left;
}
.font-color {
color: red;
font-size: 25px;
}
.green {
color: green;
}
h3 {
padding-bottom: 5px;
border-bottom: 2px solid #ccc;
}
</style>
</head>
<body>
<div>
<div class="container">
<div class="row">
<div class=" col-md-4 ">
<h3>脆皮虾王</h3>
<img src="meishi1.jpg" alt="">
<h6 class="green"><span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span>两种口味可供选择
</h6>
<div>
<button class="btn btn-block btn-danger">添加到购物车</button>
</div>
<div class="font-color">一口价:¥45.00</div>
</div>
<div class=" col-md-4 ">
<h3>剁椒香辣鱼</h3>
<img src="meishi2.jpg" alt="">
<h6 class="green"><span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span>三种口味可供选择
</h6>
<div>
<button class="btn btn-block btn-danger">添加到购物车</button>
</div>
<div class="font-color">一口价:¥95.00</div>
</div>
<div class=" col-md-4 ">
<h3>洪七公串串</h3>
<img src="meishi3.jpeg" alt="">
<h6 class="green"><span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span>两种口味可供选择
</h6>
<div>
<button class="btn btn-block btn-danger" type="">添加到购物车</button>
</div>
<div class="font-color">一口价:¥65.00</div>
</div>
</div>
</div>
</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery,所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
</body>
</html>
里面涉及到几张图片,你们可以换成自己喜欢的没事图片就行,也可以用下面的图片: