bootstrap知识小点
年底没什么项目做了,整理下最近做的网站使用到的bootstrap知识
一、导入bootstrap样式和脚本
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <script src="js/bootstrap.min.js" type="text/javascript"></script>
二、导航条
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="brand pull-left" href="#">RenderKa </a> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <div class="nav-collapse collapse"> <div class="icon_home"><a href="Index.aspx" target="_blank">CN</a>/EN</div> <ul id="nav-list" class="nav pull-right"> <li><a href="#price">Price</a></li> <li><a href="#support">Support</a></li> <li><a href="#workflow">Workflow</a></li> <li><a href="#contact">Contact</a></li> </ul> </div> </div> </div> </div>
1、.navbar class 添加 class .navbar-fixed-top:表示让导航栏固定在页面的顶部
2、.brand class: 以不同的方式显示
3、.pull-left: 靠左对齐
4、为了给导航栏添加响应式特性,您要折叠的内容必须包裹在带有 classes .collapse、.navbar-collapse 的 <div> 中。折叠起来的导航栏实际上是一个带有 class .navbar-toggle 及两个 data- 元素的按钮。第一个是 data-toggle,用于告诉 JavaScript 需要对按钮做什么,第二个是 data-target,指示要切换到哪一个元素。三个带有 class .icon-bar 的 <span> 创建所谓的汉堡按钮。这些会切换为.nav-collapse <div> 中的元素。
三、布局容器
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<div class="container container-fluid"> <div class="row-fluid" id="workflow"> <h1 class="page-title" >Workflow <a href="#price" class="arrow-top"> <img src="img/arrow-top.png"> </a> </h1> <div class="span2" style="font-size:13px;"><img src="img/kefu1.jpg" /> contact our customer service via Skype or email to place your order </div> <div class="span1" style="margin-top:50px;"><img src="img/Arrows.jpg" /></div> <div class="span2" style="font-size:13px;"><img src="img/wendong1.jpg" /> upload your archived scene file including all materials and setups </div> <div class="span1" style="margin-top:50px;"><img src="img/Arrows.jpg" /></div> <div class="span2" style="font-size:13px;"><img src="img/times1.jpg" /> we will send testframes to confirm that everything works fine at our end after your confirmation we will proceed start rendering </div> <div class="span1" style="margin-top:50px;"><img src="img/Arrows.jpg" /></div> <div class="span2" style="font-size:13px;"><img src="img/xiazai1.jpg" /> after we received the payment we will send the files via dropbox or ftp </div> </div> </div>
1、.container class: 用于固定宽度并支持响应式布局的容器
2、.container-fluid: 用于 100% 宽度,占据全部视口(viewport)的容器
3、1个row里最多12个span
四、滚动监听
1、引入js:<script src="js/bootstrap-scrollspy.js" type="text/javascript"></script>
2、(1)向您想要监听的元素(通常是 body)添加 data-spy="scroll",然后添加带有 Bootstrap .nav 组件的父元素的 ID 或 class 的属性 data-target
(2)
$("#nav-list li, #scroll_up").click(function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: $($(this).children("a").attr("href")).offset().top },1500); });