├─ /weijinsuo/ ··················· 项目所在目录 └─┬─ /css/ ······················· 咱们本身的CSS文件 ├─ /font/ ······················ 使用到的字体文件 ├─ /img/ ······················· 使用到的图片文件 ├─ /js/ ························ 本身写的JS脚步 ├─ /lib/ ······················· 从第三方下载回来的库【只用不改】 ├─ /favicon.ico ················ 站点图标 └─ /index.html ················· 入口文件
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>页面标题</title> </head> <body> </body> </html>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
html中插入视口设置,能够经过emmet meta:vp 插入javascript
<meta http-equiv="X-UA-Compatible" content="IE=edge">
html中插入兼容模式设置,能够经过emmet meta:compat 插入css
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
html中插入图标连接,能够经过emmet link:favicon 插入html
<link rel="stylesheet" href="bootstrap.css"> <link rel="stylesheet" href="my.css"> ... <script src="jquery.js"></script> <script src="bootstrap.js"></script> <script src="my.js"></script>
body{ font-family: "Helvetica Neue", Helvetica, Microsoft Yahei, Hiragino Sans GB, WenQuanYi Micro Hei, sans-serif; }
先划分好页面中的大容器,而后在具体看每个容器中单独的状况,代码中的注释的格式也要学习下哦前端
<body> <!-- 头部区域 --> <header></header> <!-- /头部区域 --> <!-- 广告轮播 --> <section></section> <!-- /广告轮播 --> <!-- 特点介绍 --> <section></section> <!-- /特点介绍 --> <!-- 当即预定 --> <section></section> <!-- /当即预定 --> <!-- 产品推荐 --> <section></section> <!-- /产品推荐 --> <!-- 新闻列表 --> <section></section> <!-- /新闻列表 --> <!-- 合做伙伴 --> <section></section> <!-- /合做伙伴 --> <!-- 脚注区域 --> <footer></footer> <!-- /脚注区域 --> </body>
<header> <div class="topbar"></div> </header>
<div class="topbar"> <div class="container"> <!-- 此处的代码会显示在一个固定宽度且居中的容器中 该容器的宽度会跟随屏幕的变化而变化 --> </div> </div>
<div class="container"> <div class="row"></div> </div>
<div class="row"> <div class="col-md-2 text-center"></div> <div class="col-md-5 text-center"></div> <div class="col-md-2 text-center"></div> <div class="col-md-3 text-center"></div> </div>
此处顶部通栏已经被划分为四列
text-center的做用就是让内部内容居中显示html5
@font-face { font-family: 'weijinsuo'; src: url('../font/MiFie-Web-Font.eot') format('embedded-opentype'), url('../font/MiFie-Web-Font.svg') format('svg'), url('../font/MiFie-Web-Font.ttf') format('truetype'), url('../font/MiFie-Web-Font.woff') format('woff'); } [class^="icon-"], [class*=" icon-"] { /*注意上面选择器中间的空格*/ /*咱们使用的名为itcast的字体就是上面的@font-face的方式声明的*/ font-family: weijinsuo; font-style: normal; } .icon-mobilephone::before{ content: '\e908'; }
<div class="col-md-2 text-center"> <a class="mobile-link" href="#"> <i class="icon-mobile"></i> <span>手机微金所</span> <!-- 这里使用的是bootstrap中的字体图标 --> <i class="glyphicon glyphicon-chevron-down"></i> <img src="..." alt=""> </a> </div>
.mobile-link:hover > img { display: block; }
.btn-itcast { color: #ffffff; background-color: #E92322; border-color: #DB3B43; } .btn-itcast:hover, .btn-itcast:focus, .btn-itcast:active, .btn-itcast.active, .open .dropdown-toggle.btn-itcast { color: #ffffff; background-color: #E92322; border-color: #DB3B43; } .btn-itcast:active, .btn-itcast.active, .open .dropdown-toggle.btn-itcast { background-image: none; } .btn-itcast.disabled, .btn-itcast[disabled], fieldset[disabled] .btn-itcast, .btn-itcast.disabled:hover, .btn-itcast[disabled]:hover, fieldset[disabled] .btn-itcast:hover, .btn-itcast.disabled:focus, .btn-itcast[disabled]:focus, fieldset[disabled] .btn-itcast:focus, .btn-itcast.disabled:active, .btn-itcast[disabled]:active, fieldset[disabled] .btn-itcast:active, .btn-itcast.disabled.active, .btn-itcast[disabled].active, fieldset[disabled] .btn-itcast.active { background-color: #E92322; border-color: #DB3B43; } .btn-itcast .badge { color: #E92322; background-color: #ffffff; }
<div class="topbar hidden-xs hidden-sm"></div>
或者java
<div class="topbar visible-md visible-lg"></div>
hidden-xx : 在某种屏幕下隐藏
visible-xx : 在某种屏幕尺寸下显示jquery
<nav class="navbar navbar-itcast navbar-static-top"> <div class="container"> <div class="navbar-header"> <button id="btn" type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav_list" aria-expanded="false"> <span class="sr-only">切换菜单</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"> <i class="icon-icon"></i> <i class="icon-logo"></i> </a> </div> <div id="nav_list" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">我要投资</a></li> <li><a href="#">我要借款</a></li> <li><a href="#">平台介绍</a></li> <li><a href="#">新手专区</a></li> <li><a href="#">最新动态</a></li> <li><a href="#">微论坛</a></li> </ul> <ul class="nav navbar-nav navbar-right hidden-sm"> <li><a href="#">我的中心</a></li> </ul> </div> </div> </nav>
.navbar-weijinsuo{ ... } ...具体代码参考navbar-default实现便可,根据本身的实际要求修改外观
对于Bootstrap的JS插件,咱们只须要将文档实例中的代码粘到咱们本身的代码中
而后作出相应的样式调整web
<!-- 如下容器就是整个轮播图组件的总体, 注意该盒子必须加上 class="carousel slide" data-ride="carousel" 表示当前是一个轮播图 bootstrap.js会自动为当前元素添加图片轮播的特效 --> <div id="轮播图的ID" class="carousel slide" data-ride="carousel"> <!-- ol标签是图片轮播的控制点 --> <ol class="carousel-indicators"> <!-- 每个li就是一个单独的控制点 data-target属性就是指定当前控制点控制的是哪个轮播图,其目的是若是界面上有多个轮播图,便于区分到底控制哪个 data-slide-to属性是指当前的li元素绑定的是第几个轮播项 注意,默认必须给其中某个li加上active,展现的时候就是焦点项目 --> <li data-target="#轮播图的ID" data-slide-to="0" class="active"></li> <li data-target="#轮播图的ID" data-slide-to="1"></li> <!-- ...更多的 --> </ol> <!-- .carousel-inner是全部轮播项的容器盒子, 注意role="listbox"表明当前div是一个列表盒子,做用就是给当前div添加一个语义 --> <div class="carousel-inner" role="listbox"> <!-- 每个.item就是单个轮播项目,注意默认要给第一个轮播项目加上active,表示为焦点 --> <div class="item active"> <!-- 轮播项目中展现的图片 --> <img src="example.jpg" alt="示例图片"> <div class="carousel-caption"> <!-- 标题或说明性文字,若是不须要,直接删除当前div.carousel-caption --> </div> </div> <div class="item"> <!-- ... --> </div> <!-- ... --> </div> <!-- 图片轮播上左右两个控制按钮,分别点击能够滚动到上一张和下一张 --> <!-- 此处须要注意的是 该a连接的href属性必须指向须要控制的轮播图ID --> <!-- 另外a连接中的data-slide="prev"表明点击该连接会滚到上一张,若是设置为next的话则相反 --> <a class="left carousel-control" href="#轮播图的ID" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">上一张</span> </a> <a class="right carousel-control" href="#轮播图的ID" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">下一张</span> </a> </div>
$(function() { $(window).on("resize", resize).triggerHandler("resize"); /** * 屏幕宽度改变触发的方法 * @return {[type]} [description] */ function resize() { // 获取屏幕宽度 var windowW = $(window).width(); var isSmallScreen = windowW < 768; // 遍历轮播图片 $("#weijinsuo_ad > .carousel-inner > .item").each(function(i, ele) { // ele是DOM对象,因此须要转换 var $ele = $(ele); console.log($ele.data("img-sm")); var imgURL = isSmallScreen ? "url(" + $ele.data("img-sm") + ")" : "url(" + $ele.data("img-lg") + ")"; // 设置背景图片 $ele.css("backgroundImage", imgURL); if (isSmallScreen) { // 小屏幕不用背景图,直接用img $ele.html('<img src="' + $ele.data("img-sm") + '" alt="">'); } else { $ele.empty(); } }); } /** * 初始化Bootstrap中的提示框效果 * @type {String} */ $('[data-toggle="tooltip"]').tooltip(); });
function 窗口变化后执行的函数名(){ // 具体的操做 } $(window).on('resize', 窗口变化后执行的函数名);
... $(window).on('resize', 窗口变化后执行的函数名).triggerHandler('resize');
// 由于咱们须要小图时 尺寸等比例变化,因此小图时咱们使用img方式 if (isSmallScreen) { $item.html('<img src="' + imgSrc + '" alt="" />'); } else { $item.empty(); }
#weijinsuo_ad > .carousel-inner > .item { background-repeat: no-repeat; background-position: center center; -webkit-background-size: cover; background-size: cover; } @media screen and (min-width: 768px) { #weijinsuo_ad > .carousel-inner > .item { height: 410px; } } #weijinsuo_ad > .carousel-inner > .item > img { width: 100%; }
<div class="col-sm-6 col-md-4"> <!-- ... --> </div> <!-- ... -->
<a href="#"> <div class="media"> <div class="media-left"> <i class="icon-uniE907"></i> </div> <div class="media-body"> <h4 class="media-heading">支付交易保障</h4> <p>银联支付全称保证支付安全</p> </div> </div> </a>
选项卡功能能够经过Bootstrap中提供的相应组件实现
http://v3.bootcss.com/javascript/#tabsbootstrap
<div class="container"> <!-- 全部的选项卡标签,每一个标签点击分别对应面板展现出来 --> <ul class="nav nav-tabs" role="tablist"> <!-- 下面的li定义了一个选项卡的标签,其中a标签的href属性指向的就是对应要展开的面板ID aria-controls属性是说当前a连接控制的是哪一个元素(注意此属性和功能无关,只是语义) 注意必定要给a标签加上data-toggle="tab",若是不加则boostrap没法知道这是一个选项卡标签,也就不会有相应的效果 --> <li role="presentation" class="active"><a href="#第一个标签的ID" aria-controls="第一个标签的ID" role="tab" data-toggle="tab">标签页1</a></li> <li role="presentation"><a href="#第二个标签的ID" aria-controls="第二个标签的ID" role="tab" data-toggle="tab">标签页2</a></li> </ul> <!-- Tab panes --> <div class="tab-content"> <!-- .tab-pane定义当前是一个tab面板,经过id和选项卡标签关联起来 --> <div role="tabpanel" class="tab-pane active" id="第一个标签的ID"> <!-- 标签展开后的内容 --> </div> <div role="tabpanel" class="tab-pane" id="第二个标签的ID">...</div> </div> </div>
.panel-czbk > .panel-heading::before, .panel-czbk > .panel-heading::after { content: ' '; width: 16px; height: 16px; border-radius: 8px; background-color: #f0f0f0; position: absolute; } .panel-czbk > .panel-heading::before { top: -8px; left: -8px; } .panel-czbk > .panel-heading::after { bottom: -8px; left: -8px; box-shadow: 0 2px 1px #ccc inset; }