利用Bootstrap 框架来制作栅格系统与轮播图
Bootstrap框架
简介:BS是用来做响应式页面的前端UI框架,它提供了栅格系统、样式布局、API供我们直接使用。
使用方法:
官网打开后下载即可,或者通过包管理工具用命令下载
2、环境搭建相关代码(引入主要文件)
Bootstrap栅格系统
绝对要明白的 Bootstrap 类名
.container:代表版心
.container-fluid:代表通屏
浏览器会默认把页面分为12个档
BS的设计者把所有的终端设备按分辨率来分成4个档:
col-lg-num >= 1200px 版心1170px 盒子在大屏幕下占num列
col-md-num >=992px 版心970px 盒子在中等屏幕、大屏幕下占num列
col-sm-num >=768px 版心750px 盒子在小屏幕、中等屏幕、大屏幕下占num列
col-xs-num <768px 版心自动撑满 超小屏幕(手机) 盒子在所有屏幕下占num列
在把屏幕分辨率分为4档之后,再把版心分成12列,让盒子占其中的多少列,因为版心宽度不同,盒子在不同档次的分辨率下实际宽度就不同了,所以利用栅格系统把盒子做成响应式。
//原理 : 注意 绑定直接使用行内写相关类名
<div class="container">
<div class="col-md-3 col-sm-6 col-xs-12 bg-danger">盒子1</div>
<div class="col-md-3 col-sm-6 col-xs-12 bg-primary">盒子2</div>
<div class="col-md-3 col-sm-6 col-xs-12 bg-success">盒子3</div>
<div class="col-md-3 col-sm-6 col-xs-12 bg-info">盒子4</div>
</div>
Bootstrap的carousel 完成轮播图
<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>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通