移动端网页特效

一、案例:

 

 

 

 

HTML代码“:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./css/normalize.css">
    <link rel="stylesheet" href="./css/index.css">
    <title>携程在手,说走就走</title>
    <script src="./js/index.js"></script>
</head>
<body>
    <!-- 返回顶部模块 -->
    <div class="goBack"></div>
    <!-- 顶部搜索 -->
    <div class="search-index">
        <div class="search">搜索:目的地/酒店/景点/航班号</div>
        <a href="#" class="user">我 的</a>
    </div>

    <!-- 焦点图模块 -->
    <div class="focus">
        <ul>
            <li><img src="./upload/focus3.jpg" alt=""></li>
            <li><img src="./upload/focus1.jpg" alt=""></li>
            <li><img src="./upload/focus2.jpg" alt=""></li>
            <li><img src="./upload/focus3.jpg" alt=""></li>
            <li><img src="./upload/focus1.jpg" alt=""></li>
           
        </ul>

        <!-- 小圆点 -->
        <ol>
            <li class="current"></li>
            <li></li>
            <li></li>
        </ol>
    </div>

    <!-- 局部导航栏 -->
    <ul class="local-nav">
        <li>
            <a href="#" title="景点.玩乐">
                <span class="local-nav-icon-icon1"></span>
                <span>景点.玩乐</span>
            </a>
        </li>
        <li>
            <a href="#" title="景点.玩乐">
                <span class="local-nav-icon-icon2"></span>
                <span>景点.玩乐</span>
            </a>
        </li>
        <li>
            <a href="#" title="景点.玩乐">
                <span class="local-nav-icon-icon3"></span>
                <span>景点.玩乐</span>
            </a>
        </li>
        <li>
            <a href="#" title="景点.玩乐">
                <span class="local-nav-icon-icon4"></span>
                <span>景点.玩乐</span>
            </a>
        </li>
        <li>
            <a href="#" title="景点.玩乐">
                <span class="local-nav-icon-icon5"></span>
                <span>景点.玩乐</span>
            </a>
        </li>
    </ul>

    <!-- 主导航栏 -->
    <nav>
        <div class="nav-common">
            <div class="nav-items">
                <a href="#">海外酒店</a>
            </div>
            <div class="nav-items">
                <a href="#">海外酒店</a>
                <a href="#">特价酒店</a>
            </div>
            <div class="nav-items">
                <a href="#">海外酒店</a>
                <a href="#">特价酒店</a>
            </div>
        </div>
        <div class="nav-common">
            <div class="nav-items">
                <a href="#">海外酒店</a>
            </div>
            <div class="nav-items">
                <a href="#">海外酒店</a>
                <a href="#">特价酒店</a>
            </div>
            <div class="nav-items">
                <a href="#">海外酒店</a>
                <a href="#">特价酒店</a>
            </div>
        </div>
        <div class="nav-common">
            <div class="nav-items">
                <a href="#">海外酒店</a>
            </div>
            <div class="nav-items">
                <a href="#">海外酒店</a>
                <a href="#">特价酒店</a>
            </div>
            <div class="nav-items">
                <a href="#">海外酒店</a>
                <a href="#">特价酒店</a>
            </div>
        </div>
    </nav>

    <!-- 侧导航栏 -->
    <ul class="subnav-entry">
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
        <li>
            <a href="#">
                <span class="subnav-entry-icon"></span>
                <span>电话费</span>
            </a>
        </li>
    </ul>

    <!-- 销售模块 -->
    <div class="sales-box">
        <div class="sales-hd">
            <h2>热门活动</h2>
            <a href="#" class="more">获取更多福利</a>
        </div>
        <div class="sales-bd">
            <div class="row">
                <a href="#">
                    <img src="./upload/pic1.jpg" alt="">
                </a>
                <a href="#">
                    <img src="./upload/pic2.jpg" alt="">
                </a>
            </div>
            <div class="row">
                <a href="#">
                    <img src="./upload/pic3.jpg" alt="">
                </a>
                <a href="#">
                    <img src="./upload/pic4.jpg" alt="">
                </a>
            </div>
            <div class="row">
                <a href="#">
                    <img src="./upload/pic5.jpg" alt="">
                </a>
                <a href="#">
                    <img src="./upload/pic6.jpg" alt="">
                </a>
            </div>
        </div>
    </div>
</body>
</html>

CSS:

body{
    max-width: 540px;
    min-width: 320px;
    margin: 0 auto;
    font: normal 14px/1.5 Tahoma, 'Lucida Grande', Verdana, 'Microsoft Yahei', STXihei,hei;
    color: #000;
    background: #f2f2f2;
    overflow-x: hidden;
    -webkit-tap-highlight-color:  transparent;
}

ul{
    list-style: none;
    margin: 0;
    padding: 0;
}
a{
    text-decoration: none;
    color: #222;
}
div{
    box-sizing: border-box;
}

/* 搜索模块 */
.search-index{
    display: flex;
    /* 固定定位跟父级没有关系,它以屏幕为准 */
    position: fixed;
    top: 0;
    left: 50%;
    z-index: 999;
    /* 固定的盒子应该有宽度 */
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    width: 100%;
    min-width: 320px;
    max-width: 540px;
    height: 44px;
    background-color:#F6F6F6;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;

}

.search{
    position: relative;
    height: 26px;
    line-height: 24px;
    border: 1px solid #ccc;
    flex: 1;
    font-size: 12px;
    color: #666;
    margin: 7px 10px;
    padding-left: 25px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0 , 0 , 0 , .2);
}

.search::before{
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    width: 15px;
    height: 15px;
    background: url('../images/sprite.png') no-repeat -59px -279px;
    background-size: 104px auto;
}

.user{
    width: 44px;
    height: 44px;
    font-size: 12px;
    text-align: center;
    color: #2eaae0;
}
.user::before{
    content: '';
    display: block;
    width: 23px;
    height: 23px;
    background: url('../images/sprite.png') no-repeat -59px -194px;
    background-size: 104px auto;
    margin: 4px auto -2px;

}

/* goBack */

.goBack{
    display: none;
    position: fixed;
    bottom: 50px;
    right: 20px;
    width: 38px;
    height: 38px;
    background: url(../images/back.png) no-repeat;
    background-size: 38px 38px;
}

/* focus */
.focus{
    position: relative;
    padding-top: 44px;
    overflow: hidden;
}

.focus img{
    width: 100%;
}

.focus ul{
    overflow: hidden;
    width: 500%;
    margin-left: -100%;
}
.focus ul li{
    float: left;
    width: 20%;
}
.focus ol{
    position: absolute;
    bottom: 5px;
    right: 5px;
    margin: 0;
}
.focus ol li{
    display: inline-block;
    width: 5px;
    height: 5px;
    background-color: #fff;
    list-style: none;
    border-radius: 2px;
    transition: all .3s;
}
.fooucs ol li.current{
    width: 15px;
}

/* local-nav */
.local-nav{
    display: flex;
    height: 64px;
    margin: 3px 4px;
    background-color: #fff;
    border-radius: 8px;
}

.local-nav li{
    flex: 1;

}
.local-nav a{
    display: flex;
    flex-direction: column;
      /* 侧轴居中对齐 因为是单行 */
    align-items: center;
    font-size: 12px;
}
.local-nav li [class^="local-nav-icon"]{
    width: 32px;
    height: 32px;
    background-color: pink;
    margin-top: 8px;
    background: url(../images/localnav_bg.png) no-repeat 0 0;
    background-size: 32px auto;
}
.local-nav li .local-nav-icon-icon2{
    background-position: 0 -32px;
}
.local-nav li .local-nav-icon-icon3{
    background-position: 0 -64px;
}
.local-nav li .local-nav-icon-icon4{
    background-position: 0 -96px;
}
.local-nav li .local-nav-icon-icon5{
    background-position: 0 -128px;
}


/* nav */
nav{
    overflow: hidden;
    border-radius: 8px;
    margin: 0 4px 3px;
}

.nav-common{
    display: flex;
    height: 88px;
    background-color: tomato;
}
.nav-common:nth-child(2){
    margin: 3px 0;
}
.nav-items{
    /* 不冲突 */
    flex: 1;
    display: flex;
    flex-direction: column;
}

.nav-items a{
    flex: 1;
    text-align: center;
    line-height: 44px;
    color: #fff;
    font-size: 14px;
    /* 文字阴影 */
    text-shadow: 1px 1px rgba(0 , 0 , 0 , .2);
}
.nav-items a:nth-child(1){
    border-bottom: 1px solid #fff;
}
.nav-items:nth-child(1) a{
    border: 0;
    background: url(../images/hotel.png) no-repeat bottom center;
    background-size: 121px auto;
}

/* -n+2 就是选择前面两个元素 */
.nav-items:nth-child(-n+2){
    border-right: 1px solid #fff;
}
.nav-common:nth-child(1){
    background:-webkit-linear-gradient(left, #FA5A55, #FA994D);
}
.nav-common:nth-child(2){
    background:-webkit-linear-gradient(left, #4B90ED, #53BCED);
}

.nav-common:nth-child(3){
    background:-webkit-linear-gradient(left, #34C2A9, #6CD559);
}

/* subnav-entry */

.subnav-entry{
    display: flex;
    border-radius: 8px;
    background-color: #fff;
    margin: 0 4px;
    flex-wrap: wrap;
    padding: 5px 0;
}
.subnav-entry li{
    /* 里面的子盒子可以写 % 相对于父级来说 */
    flex: 20%;
}

.subnav-entry a{
    display: flex;
    flex-direction: column;
    align-items: center;
}

.subnav-entry-icon{
    width: 28px;
    height: 28px;
    background-color: rosybrown;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat;
    background-size: 28px auto;
}

/* sales-box */

.sales-box{
    border-top: 1px solid #bbb;
    background-color: #fff;
    margin: 4px;
}
.sales-hd{
    position: relative;
    height: 44px;
    border-bottom: 1px solid #ccc;
}

.sales-hd h2{
    position: relative;
    text-indent: -999px;
    overflow: hidden;
}
.sales-hd h2::after{
    position: absolute;
    top: 5px;
    left: 8px;
    content: '';
    width: 79px;
    height: 15px;
    background: url(../images/hot.png) no-repeat 0 -20px;
    background-size:  79px auto;
}

.more{
    position: absolute;
    top: 0;
    right: 5px;
    background:-webkit-linear-gradient(left, #FF506C, #FF6BC6);
    border-radius: 15px;
    padding: 3px 20px 3px 10px;
    color: #fff;
}

.more::after{
    content: '';
    position: absolute;
    top: 9px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-top: 2px solid #FFF;
    border-right: 2px solid #FFF;
    transform: rotate(45deg);
}
.row{
    display: flex;
}
.row a{
    flex: 1;
    border-bottom:  1px solid #eee;
}
.row a:nth-child(1){
    border-right: 1px solid #eee;
}
.row a img{
    width: 100%;
}


JS:

window.addEventListener('load',function(){
    // 1、获取元素
    var focus = document.querySelector('.focus');
    var ul = focus.children[0];
    //获得focus的宽度
    var w = focus.offsetWidth;
    var ol = focus.children[1];
    // 2、利用定时器自动轮播图片
    var index = 0;
    var timer = this.setInterval(function(){
        index++;
        var translatex = -index * w;
        ul.style.transition = 'all .5s';
        ul.style.transform = 'translate('+translatex+'px)';
    },2000);
    // 等着过渡完成之后,再去判断监听过渡的事件  transitionend
    ul.addEventListener('transitionend',function(){
        // 无缝滚动
        if(index >= 3){
            index = 0;
            // console.log(1);
            // 去掉过渡效果,这样让ul 快速的跳到目标位置
        ul.style.transition = 'none';
        // 利用最新的索引号乘以宽度去滚动图片
        var translatex = -index * w;
        ul.style.transform = 'translate('+translatex+'px)';
        } else if(index < 0){
            index = 2;
            ul.style.transition = 'none';
            // 利用最新的索引号乘以宽度去滚动图片
            var translatex = -index * w;
            ul.style.transform = 'translate('+translatex+'px)';
        }
        //3.小圆点跟随变化
        //把 ol 里面的li 带有current 雷鸣的选出来去掉类名 remove 
        ol.querySelector('.current').classList.remove('current')
        // 让当前的索引号的 小li 加上 current add
        ol.children[index].classList.add('current')



    });

    //4.手指滑动轮播图
    //触摸元素 touchstrat :获取手指初始坐标
    var  startX = 0;
    var moveX = 0;    //后面会使用,所以要定义一个全局变量
    var flag = false;
    ul.addEventListener('touchstart', function(e){
        startX = e.targetTouches[0].pageX;
        //手指触摸的时候就停止定时器
        clearInterval(timer);
    })
    //移动手指 touchmove :计算手指的滑动距离,并且移动盒子
   
    ul.addEventListener('touchmove', function(e){
        //计算移动距离
        moveX =e.targetTouches[0].pageX - startX;
        //移动盒子 :盒子原来的位置+手指移动的距离
        var translatex = -index * w + moveX;
        //手指拖动的时候,不需要动画效果,所以要取消过渡效果
        ul.style.transition = 'none';
        ul.style.transform = 'translate('+translatex+'px)';
        flag = true;  //如果用户手指移动过再去判断是否不做判断效果
        e.preventDefault();  //阻止屏幕滚动的行为
    });

    //手指离开 根据移动距离去判断是回弹还是播放上一张下一张

    ul.addEventListener('touchend', function(e){
      if(flag){
           //(1)如果移动距离大于 50像素,就播放上一张或者下一张
       if(Math.abs(moveX) >50){
        //如果是右滑,就是播放上一张 moveX 是正值
        if(moveX >0){
            index--;
        }else {
              //如果是左滑,就是播放下一张 moveX 是负值
              index++;
        }
         var translatex = -index * w;
         ul.style.transition = 'all .3s';
         ul.style.transform = 'translateX('+translatex+'px)';
    } else{
        //(2) 如果移动距离小于50像素就回弹
        var translatex = -index * w;
        ul.style.transition = 'all .1s';
        ul.style.transform = 'translateX('+translatex+'px)';
    }
      }
       //手指离开的时候就重新开启定时器
       clearInterval(timer);
       timer =setInterval(function(){
        index++;
        var translatex = -index * w;
        ul.style.transition = 'all .5s';
        ul.style.transform = 'translateX('+translatex+'px)';
    },2000);
    });

    //返回顶部模块制作
    var goBack =document.querySelector('.goBack');
    var nav = document.querySelector('nav');
    window.addEventListener('scroll', function(){
        if(window.pageYOffset >= nav.offsetTop){
            goBack.style.display = 'block';
        } else {
            goBack.style.display = 'none';

        }
    });
    goBack.addEventListener('click',function(){
        window.scroll(0 , 0);
    })
})

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bg{
            background-color: #000;
        }
    </style>
</head>
<body>
    <div class="one"></div>
    <button>开关灯</button>
    <script>
        // classList 返回元素的类名
        var div =document.querySelector('div')
        // console.log(div.classList[1]);
        // 1.添加类名  实在后面追加类名,不会覆盖以前的类名,注意前面不需要加.
        div.classList.add('two');

        // 2.移除类名
        div.classList.remove('one');
        

        //3.切换类名
         var btn = document.querySelector('button');
         btn.addEventListener('click',function(){
             document.body .classList.toggle('bg');
         })


    </script>
</body>
</html>

 

 

 

 

 fastclick.js


;(function () {

	'use strict';



	/**

	 * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.

	 *

	 * @codingstandard ftlabs-jsv2

	 * @copyright The Financial Times Limited [All Rights Reserved]

	 * @license MIT License (see LICENSE.txt)

	 */



	/*jslint browser:true, node:true*/

	/*global define, Event, Node*/





	/**

	 * Instantiate fast-clicking listeners on the specified layer.

	 *

	 * @constructor

	 * @param {Element} layer The layer to listen on

	 * @param {Object} [options={}] The options to override the defaults

	 */

	function FastClick(layer, options) {

		var oldOnClick;



		options = options || {};



		/**

		 * Whether a click is currently being tracked.

		 *

		 * @type boolean

		 */

		this.trackingClick = false;





		/**

		 * Timestamp for when click tracking started.

		 *

		 * @type number

		 */

		this.trackingClickStart = 0;





		/**

		 * The element being tracked for a click.

		 *

		 * @type EventTarget

		 */

		this.targetElement = null;





		/**

		 * X-coordinate of touch start event.

		 *

		 * @type number

		 */

		this.touchStartX = 0;





		/**

		 * Y-coordinate of touch start event.

		 *

		 * @type number

		 */

		this.touchStartY = 0;





		/**

		 * ID of the last touch, retrieved from Touch.identifier.

		 *

		 * @type number

		 */

		this.lastTouchIdentifier = 0;





		/**

		 * Touchmove boundary, beyond which a click will be cancelled.

		 *

		 * @type number

		 */

		this.touchBoundary = options.touchBoundary || 10;





		/**

		 * The FastClick layer.

		 *

		 * @type Element

		 */

		this.layer = layer;



		/**

		 * The minimum time between tap(touchstart and touchend) events

		 *

		 * @type number

		 */

		this.tapDelay = options.tapDelay || 200;



		/**

		 * The maximum time for a tap

		 *

		 * @type number

		 */

		this.tapTimeout = options.tapTimeout || 700;



		if (FastClick.notNeeded(layer)) {

			return;

		}



		// Some old versions of Android don't have Function.prototype.bind

		function bind(method, context) {

			return function() { return method.apply(context, arguments); };

		}





		var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];

		var context = this;

		for (var i = 0, l = methods.length; i < l; i++) {

			context[methods[i]] = bind(context[methods[i]], context);

		}



		// Set up event handlers as required

		if (deviceIsAndroid) {

			layer.addEventListener('mouseover', this.onMouse, true);

			layer.addEventListener('mousedown', this.onMouse, true);

			layer.addEventListener('mouseup', this.onMouse, true);

		}



		layer.addEventListener('click', this.onClick, true);

		layer.addEventListener('touchstart', this.onTouchStart, false);

		layer.addEventListener('touchmove', this.onTouchMove, false);

		layer.addEventListener('touchend', this.onTouchEnd, false);

		layer.addEventListener('touchcancel', this.onTouchCancel, false);



		// Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)

		// which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick

		// layer when they are cancelled.

		if (!Event.prototype.stopImmediatePropagation) {

			layer.removeEventListener = function(type, callback, capture) {

				var rmv = Node.prototype.removeEventListener;

				if (type === 'click') {

					rmv.call(layer, type, callback.hijacked || callback, capture);

				} else {

					rmv.call(layer, type, callback, capture);

				}

			};



			layer.addEventListener = function(type, callback, capture) {

				var adv = Node.prototype.addEventListener;

				if (type === 'click') {

					adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {

						if (!event.propagationStopped) {

							callback(event);

						}

					}), capture);

				} else {

					adv.call(layer, type, callback, capture);

				}

			};

		}



		// If a handler is already declared in the element's onclick attribute, it will be fired before

		// FastClick's onClick handler. Fix this by pulling out the user-defined handler function and

		// adding it as listener.

		if (typeof layer.onclick === 'function') {



			// Android browser on at least 3.2 requires a new reference to the function in layer.onclick

			// - the old one won't work if passed to addEventListener directly.

			oldOnClick = layer.onclick;

			layer.addEventListener('click', function(event) {

				oldOnClick(event);

			}, false);

			layer.onclick = null;

		}

	}



	/**

	* Windows Phone 8.1 fakes user agent string to look like Android and iPhone.

	*

	* @type boolean

	*/

	var deviceIsWindowsPhone = navigator.userAgent.indexOf("Windows Phone") >= 0;



	/**

	 * Android requires exceptions.

	 *

	 * @type boolean

	 */

	var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone;





	/**

	 * iOS requires exceptions.

	 *

	 * @type boolean

	 */

	var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone;





	/**

	 * iOS 4 requires an exception for select elements.

	 *

	 * @type boolean

	 */

	var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);





	/**

	 * iOS 6.0-7.* requires the target element to be manually derived

	 *

	 * @type boolean

	 */

	var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS [6-7]_\d/).test(navigator.userAgent);



	/**

	 * BlackBerry requires exceptions.

	 *

	 * @type boolean

	 */

	var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;



	/**

	 * Determine whether a given element requires a native click.

	 *

	 * @param {EventTarget|Element} target Target DOM element

	 * @returns {boolean} Returns true if the element needs a native click

	 */

	FastClick.prototype.needsClick = function(target) {

		switch (target.nodeName.toLowerCase()) {



		// Don't send a synthetic click to disabled inputs (issue #62)

		case 'button':

		case 'select':

		case 'textarea':

			if (target.disabled) {

				return true;

			}



			break;

		case 'input':



			// File inputs need real clicks on iOS 6 due to a browser bug (issue #68)

			if ((deviceIsIOS && target.type === 'file') || target.disabled) {

				return true;

			}



			break;

		case 'label':

		case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames

		case 'video':

			return true;

		}



		return (/\bneedsclick\b/).test(target.className);

	};





	/**

	 * Determine whether a given element requires a call to focus to simulate click into element.

	 *

	 * @param {EventTarget|Element} target Target DOM element

	 * @returns {boolean} Returns true if the element requires a call to focus to simulate native click.

	 */

	FastClick.prototype.needsFocus = function(target) {

		switch (target.nodeName.toLowerCase()) {

		case 'textarea':

			return true;

		case 'select':

			return !deviceIsAndroid;

		case 'input':

			switch (target.type) {

			case 'button':

			case 'checkbox':

			case 'file':

			case 'image':

			case 'radio':

			case 'submit':

				return false;

			}



			// No point in attempting to focus disabled inputs

			return !target.disabled && !target.readOnly;

		default:

			return (/\bneedsfocus\b/).test(target.className);

		}

	};





	/**

	 * Send a click event to the specified element.

	 *

	 * @param {EventTarget|Element} targetElement

	 * @param {Event} event

	 */

	FastClick.prototype.sendClick = function(targetElement, event) {

		var clickEvent, touch;



		// On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)

		if (document.activeElement && document.activeElement !== targetElement) {

			document.activeElement.blur();

		}



		touch = event.changedTouches[0];



		// Synthesise a click event, with an extra attribute so it can be tracked

		clickEvent = document.createEvent('MouseEvents');

		clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);

		clickEvent.forwardedTouchEvent = true;

		targetElement.dispatchEvent(clickEvent);

	};



	FastClick.prototype.determineEventType = function(targetElement) {



		//Issue #159: Android Chrome Select Box does not open with a synthetic click event

		if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {

			return 'mousedown';

		}



		return 'click';

	};





	/**

	 * @param {EventTarget|Element} targetElement

	 */

	FastClick.prototype.focus = function(targetElement) {

		var length;



		// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.

		if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') {

			length = targetElement.value.length;

			targetElement.setSelectionRange(length, length);

		} else {

			targetElement.focus();

		}

	};





	/**

	 * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.

	 *

	 * @param {EventTarget|Element} targetElement

	 */

	FastClick.prototype.updateScrollParent = function(targetElement) {

		var scrollParent, parentElement;



		scrollParent = targetElement.fastClickScrollParent;



		// Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the

		// target element was moved to another parent.

		if (!scrollParent || !scrollParent.contains(targetElement)) {

			parentElement = targetElement;

			do {

				if (parentElement.scrollHeight > parentElement.offsetHeight) {

					scrollParent = parentElement;

					targetElement.fastClickScrollParent = parentElement;

					break;

				}



				parentElement = parentElement.parentElement;

			} while (parentElement);

		}



		// Always update the scroll top tracker if possible.

		if (scrollParent) {

			scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;

		}

	};





	/**

	 * @param {EventTarget} targetElement

	 * @returns {Element|EventTarget}

	 */

	FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {



		// On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.

		if (eventTarget.nodeType === Node.TEXT_NODE) {

			return eventTarget.parentNode;

		}



		return eventTarget;

	};





	/**

	 * On touch start, record the position and scroll offset.

	 *

	 * @param {Event} event

	 * @returns {boolean}

	 */

	FastClick.prototype.onTouchStart = function(event) {

		var targetElement, touch, selection;



		// Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).

		if (event.targetTouches.length > 1) {

			return true;

		}



		targetElement = this.getTargetElementFromEventTarget(event.target);

		touch = event.targetTouches[0];



		if (deviceIsIOS) {



			// Only trusted events will deselect text on iOS (issue #49)

			selection = window.getSelection();

			if (selection.rangeCount && !selection.isCollapsed) {

				return true;

			}



			if (!deviceIsIOS4) {



				// Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):

				// when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched

				// with the same identifier as the touch event that previously triggered the click that triggered the alert.

				// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an

				// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.

				// Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,

				// which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,

				// random integers, it's safe to to continue if the identifier is 0 here.

				if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {

					event.preventDefault();

					return false;

				}



				this.lastTouchIdentifier = touch.identifier;



				// If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:

				// 1) the user does a fling scroll on the scrollable layer

				// 2) the user stops the fling scroll with another tap

				// then the event.target of the last 'touchend' event will be the element that was under the user's finger

				// when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check

				// is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).

				this.updateScrollParent(targetElement);

			}

		}



		this.trackingClick = true;

		this.trackingClickStart = event.timeStamp;

		this.targetElement = targetElement;



		this.touchStartX = touch.pageX;

		this.touchStartY = touch.pageY;



		// Prevent phantom clicks on fast double-tap (issue #36)

		if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {

			event.preventDefault();

		}



		return true;

	};





	/**

	 * Based on a touchmove event object, check whether the touch has moved past a boundary since it started.

	 *

	 * @param {Event} event

	 * @returns {boolean}

	 */

	FastClick.prototype.touchHasMoved = function(event) {

		var touch = event.changedTouches[0], boundary = this.touchBoundary;



		if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {

			return true;

		}



		return false;

	};





	/**

	 * Update the last position.

	 *

	 * @param {Event} event

	 * @returns {boolean}

	 */

	FastClick.prototype.onTouchMove = function(event) {

		if (!this.trackingClick) {

			return true;

		}



		// If the touch has moved, cancel the click tracking

		if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {

			this.trackingClick = false;

			this.targetElement = null;

		}



		return true;

	};





	/**

	 * Attempt to find the labelled control for the given label element.

	 *

	 * @param {EventTarget|HTMLLabelElement} labelElement

	 * @returns {Element|null}

	 */

	FastClick.prototype.findControl = function(labelElement) {



		// Fast path for newer browsers supporting the HTML5 control attribute

		if (labelElement.control !== undefined) {

			return labelElement.control;

		}



		// All browsers under test that support touch events also support the HTML5 htmlFor attribute

		if (labelElement.htmlFor) {

			return document.getElementById(labelElement.htmlFor);

		}



		// If no for attribute exists, attempt to retrieve the first labellable descendant element

		// the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label

		return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');

	};





	/**

	 * On touch end, determine whether to send a click event at once.

	 *

	 * @param {Event} event

	 * @returns {boolean}

	 */

	FastClick.prototype.onTouchEnd = function(event) {

		var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;



		if (!this.trackingClick) {

			return true;

		}



		// Prevent phantom clicks on fast double-tap (issue #36)

		if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {

			this.cancelNextClick = true;

			return true;

		}



		if ((event.timeStamp - this.trackingClickStart) > this.tapTimeout) {

			return true;

		}



		// Reset to prevent wrong click cancel on input (issue #156).

		this.cancelNextClick = false;



		this.lastClickTime = event.timeStamp;



		trackingClickStart = this.trackingClickStart;

		this.trackingClick = false;

		this.trackingClickStart = 0;



		// On some iOS devices, the targetElement supplied with the event is invalid if the layer

		// is performing a transition or scroll, and has to be re-detected manually. Note that

		// for this to function correctly, it must be called *after* the event target is checked!

		// See issue #57; also filed as rdar://13048589 .

		if (deviceIsIOSWithBadTarget) {

			touch = event.changedTouches[0];



			// In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null

			targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;

			targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;

		}



		targetTagName = targetElement.tagName.toLowerCase();

		if (targetTagName === 'label') {

			forElement = this.findControl(targetElement);

			if (forElement) {

				this.focus(targetElement);

				if (deviceIsAndroid) {

					return false;

				}



				targetElement = forElement;

			}

		} else if (this.needsFocus(targetElement)) {



			// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.

			// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).

			if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {

				this.targetElement = null;

				return false;

			}



			this.focus(targetElement);

			this.sendClick(targetElement, event);



			// Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.

			// Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)

			if (!deviceIsIOS || targetTagName !== 'select') {

				this.targetElement = null;

				event.preventDefault();

			}



			return false;

		}



		if (deviceIsIOS && !deviceIsIOS4) {



			// Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled

			// and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).

			scrollParent = targetElement.fastClickScrollParent;

			if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {

				return true;

			}

		}



		// Prevent the actual click from going though - unless the target node is marked as requiring

		// real clicks or if it is in the allowlist in which case only non-programmatic clicks are permitted.

		if (!this.needsClick(targetElement)) {

			event.preventDefault();

			this.sendClick(targetElement, event);

		}



		return false;

	};





	/**

	 * On touch cancel, stop tracking the click.

	 *

	 * @returns {void}

	 */

	FastClick.prototype.onTouchCancel = function() {

		this.trackingClick = false;

		this.targetElement = null;

	};





	/**

	 * Determine mouse events which should be permitted.

	 *

	 * @param {Event} event

	 * @returns {boolean}

	 */

	FastClick.prototype.onMouse = function(event) {



		// If a target element was never set (because a touch event was never fired) allow the event

		if (!this.targetElement) {

			return true;

		}



		if (event.forwardedTouchEvent) {

			return true;

		}



		// Programmatically generated events targeting a specific element should be permitted

		if (!event.cancelable) {

			return true;

		}



		// Derive and check the target element to see whether the mouse event needs to be permitted;

		// unless explicitly enabled, prevent non-touch click events from triggering actions,

		// to prevent ghost/doubleclicks.

		if (!this.needsClick(this.targetElement) || this.cancelNextClick) {



			// Prevent any user-added listeners declared on FastClick element from being fired.

			if (event.stopImmediatePropagation) {

				event.stopImmediatePropagation();

			} else {



				// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)

				event.propagationStopped = true;

			}



			// Cancel the event

			event.stopPropagation();

			event.preventDefault();



			return false;

		}



		// If the mouse event is permitted, return true for the action to go through.

		return true;

	};





	/**

	 * On actual clicks, determine whether this is a touch-generated click, a click action occurring

	 * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or

	 * an actual click which should be permitted.

	 *

	 * @param {Event} event

	 * @returns {boolean}

	 */

	FastClick.prototype.onClick = function(event) {

		var permitted;



		// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.

		if (this.trackingClick) {

			this.targetElement = null;

			this.trackingClick = false;

			return true;

		}



		// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.

		if (event.target.type === 'submit' && event.detail === 0) {

			return true;

		}



		permitted = this.onMouse(event);



		// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.

		if (!permitted) {

			this.targetElement = null;

		}



		// If clicks are permitted, return true for the action to go through.

		return permitted;

	};





	/**

	 * Remove all FastClick's event listeners.

	 *

	 * @returns {void}

	 */

	FastClick.prototype.destroy = function() {

		var layer = this.layer;



		if (deviceIsAndroid) {

			layer.removeEventListener('mouseover', this.onMouse, true);

			layer.removeEventListener('mousedown', this.onMouse, true);

			layer.removeEventListener('mouseup', this.onMouse, true);

		}



		layer.removeEventListener('click', this.onClick, true);

		layer.removeEventListener('touchstart', this.onTouchStart, false);

		layer.removeEventListener('touchmove', this.onTouchMove, false);

		layer.removeEventListener('touchend', this.onTouchEnd, false);

		layer.removeEventListener('touchcancel', this.onTouchCancel, false);

	};





	/**

	 * Check whether FastClick is needed.

	 *

	 * @param {Element} layer The layer to listen on

	 */

	FastClick.notNeeded = function(layer) {

		var metaViewport;

		var chromeVersion;

		var blackberryVersion;

		var firefoxVersion;



		// Devices that don't support touch don't need FastClick

		if (typeof window.ontouchstart === 'undefined') {

			return true;

		}



		// Chrome version - zero for other browsers

		chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];



		if (chromeVersion) {



			if (deviceIsAndroid) {

				metaViewport = document.querySelector('meta[name=viewport]');



				if (metaViewport) {

					// Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)

					if (metaViewport.content.indexOf('user-scalable=no') !== -1) {

						return true;

					}

					// Chrome 32 and above with width=device-width or less don't need FastClick

					if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {

						return true;

					}

				}



			// Chrome desktop doesn't need FastClick (issue #15)

			} else {

				return true;

			}

		}



		if (deviceIsBlackBerry10) {

			blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);



			// BlackBerry 10.3+ does not require Fastclick library.

			// https://github.com/ftlabs/fastclick/issues/251

			if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {

				metaViewport = document.querySelector('meta[name=viewport]');



				if (metaViewport) {

					// user-scalable=no eliminates click delay.

					if (metaViewport.content.indexOf('user-scalable=no') !== -1) {

						return true;

					}

					// width=device-width (or less than device-width) eliminates click delay.

					if (document.documentElement.scrollWidth <= window.outerWidth) {

						return true;

					}

				}

			}

		}



		// IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97)

		if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') {

			return true;

		}



		// Firefox version - zero for other browsers

		firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];



		if (firefoxVersion >= 27) {

			// Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896



			metaViewport = document.querySelector('meta[name=viewport]');

			if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) {

				return true;

			}

		}



		// IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version

		// http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx

		if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {

			return true;

		}



		return false;

	};





	/**

	 * Factory method for creating a FastClick object

	 *

	 * @param {Element} layer The layer to listen on

	 * @param {Object} [options={}] The options to override the defaults

	 */

	FastClick.attach = function(layer, options) {

		return new FastClick(layer, options);

	};





	if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {



		// AMD. Register as an anonymous module.

		define(function() {

			return FastClick;

		});

	} else if (typeof module !== 'undefined' && module.exports) {

		module.exports = FastClick.attach;

		module.exports.FastClick = FastClick;

	} else {

		window.FastClick = FastClick;

	}

}());

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 50px;
            height: 50px;
            background-color: aqua;
        }
    </style>
    <script src="./fastclick.js"></script>
</head>
<body>
    <div></div>

    <script>
        if ('addEventListener' in document) {
            document.addEventListener('DOMContentLoaded', function() {
                FastClick.attach(document.body);
            }, false);
        }

        var div = document.querySelector('div');
        div.addEventListener('click',function(){
            alert(1);
        });
    </script>
</body>
</html>

 

 HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入CSS初始化文件 -->
    <link rel="stylesheet" href="./css/normalize.css">
    <!-- 引入inde.css文件 -->
    <link rel="stylesheet" href="./css/index.css">
    <!-- 引入SWipercss文件 -->
    <link rel="stylesheet" href="./css/swiper.min.css">
    <!-- 引入swiper .js 文件 -->
    <script src="./js/swiper.min.js"></script>
    <!-- 引入index.js 文件 -->
    <script src="./js/index.js"></script>
    <title>Document</title>
</head>
<body>
    <!-- 顶部 -->
    <header class="app">
        <ul>
            <li>
                <img src="./images/close.png" alt="">
            </li>
            <li>
                <img src="./images/logo.png" alt="">
            </li>
            <li>打开京东App,购物更轻松</li>
            <li>立即打开</li>
        </ul>
    </header>

    <!-- 搜索 -->
    <div class="search-wrap">
        <div class="search-btn"></div>
        <div class="search">
            <div class="jd-icon"></div>
            <div class="sou"></div>
        </div>
        <div class="search-login">登录</div>
    </div>

    <!-- 主体部分 -->
    <div class="main-content">
        <!-- 滑动图 -->
        <div class="slider">
            <!-- Swiper 注意不要更改里面的结构和类名 -->
            <div class="swiper-container">
                <div class="swiper-wrapper">
                  <div class="swiper-slide">
                      <img src="./upload/banner.dpg" alt="">
                  </div>
                  <div class="swiper-slide">
                      <img src="./upload/banner1.dpg" alt="">
                  </div>
                  <div class="swiper-slide">
                      <img src="./upload/banner2.dpg" alt="">
                  </div>
                  <div class="swiper-slide">
                      <img src="./upload/banner3.dpg" alt="">
                  </div>
                 
                </div>
                
                <!-- Add Pagination -->
                <div class="swiper-pagination"></div>
            </div>
        </div>

        <!-- 小家电品牌日 -->
        <div class="brand">
            <div>
                <a href="#">
                    <img src="./upload/pic11.dpg" alt="">
                </a>
            </div>
            <div>
                <a href="#">
                    <img src="./upload/pic22.dpg" alt="">
                </a>
            </div>
            <div>
                <a href="#">
                    <img src="./upload/pic33.dpg" alt="">
                </a>
            </div>
        </div>

        <!-- nav部分 -->
        <nav class="clearfix">
            <a href="#">
                <img src="./upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav2.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav3.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>
            <a href="#">
                <img src="./upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>
        </nav>

        <!-- 新闻模块 -->
        <div class="news">
            <a href="#">
                <img src="./upload/new1.dpg" alt="">
            </a>
            <a href="#">
                <img src="./upload/new2.dpg" alt="">
            </a>
            <a href="#">
                <img src="./upload/new3.dpg" alt="">
            </a>
        </div>
    </div>
</body>
</html>

CSS:

body{
    width: 100%;
    min-width: 320px;
    max-width: 640px;
    margin: 0 auto;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    color: #666;
    line-height: 1.5;
}

/* 点击高亮需要清除清除  设置为 transparent 完成透明 */
*{
    -webkit-tap-highlight-color: transparent;
}

/* 在移动端浏览器默认的外观在iOS上加上这个属性才能给按钮个输入框自定义样式 */
input{
    -webkit-appearance: none;
}

/* 禁用长按页面是的弹出页面 */
img,
a{
    -webkit-touch-callout: none;
}

a{
    color: #666;
    text-decoration: none;
}

ul{
    margin: 0;
    padding: 0;
    list-style: none;
}

img{
    vertical-align: middle;
}

div{
    /* CSS3 盒子模型 */
    box-sizing: border-box;
}

.clearfix::after{
    content: "";
    display: block;
    line-height: 0;
    visibility: hidden;
    height: 0;
    clear: both;
}

.app{
    height: 45px;
}

.app ul li{
    float: left;
    height: 45px;
    line-height: 45px;
    background-color: #333;
    text-align: center;
    color: #fff;
}

.app ul li:nth-child(1){
    width: 8%;
}

.app ul li:nth-child(1) img{
    width: 10px;
}

.app ul li:nth-child(2){
    width: 10%;
}

.app ul li:nth-child(2) img{
    width: 30px;
    vertical-align: middle;
}

.app ul li:nth-child(3){
    width:57%;
}

.app ul li:nth-child(4) {
    width: 25%;
    background-color: #F63515;
}


/* 搜索 */
.search-wrap{
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 44px;
    min-width: 320px;
    max-width: 640px;
    z-index: 999999;
}

.search-btn{
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 44px;

}

.search-btn::before{
    content: "";
    display: block;
    width: 20px;
    height: 18px;
    background: url(../images/s-btn.png) no-repeat;
    background-size: 20px 18px;
    margin:  14px 0 0 15px;
}

.search-login{
    position: absolute;
    right: 0;
    top: 0;
    width: 40px;
    height: 44px;
    color: #fff;
    line-height: 44px;
}

.search{
    position: relative;
    height: 30px;
    background-color: #fff;
    margin: 0 50px;
    border-radius: 15px;
    margin-top: 7px;
}

.jd-icon{
    width: 20px;
    height: 15px;
    position: absolute;
    top: 8px;
    left: 13px;
    background: url(../images/jd.png) no-repeat;
    background-size: 20px 15px;
}

.jd-icon::after{
    content: "";
    position: absolute;
    right: -8px;
    top: 0;
    display: block;
    width: 1px;
    height: 15px;
    background-color: #ccc;
}

.sou{
    position: absolute;
    top: 8px;
    left: 50px;
    width: 18px;
    height: 15px;
    background: url(../images/jd-sprites.png) no-repeat -81px 0;
    background-size: 200px auto;
}

.slider img{
    width: 100%;
}

/* 复制swiper css 样式 */


.swiper-container{
    width: 100%;
    height: 100%;
}

.swiper-slide {
    text-align: center;
    font-size: 18px;
    background: #fff;
    /* Center slide text vertically */
    display: -webkit-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
}

.swiper-pagination-bullet {
    background: #fff!important;
}



/* 品牌日 */

.brand{
    overflow: hidden;
    border-radius: 10px 10px 0 0;
}

.brand div{
    float: left;
    width: 33.33%;
}

.brand div img{
    width: 100%;
}

nav{
    padding-top: 5px;
}
nav a{
    float: left;
    width: 20%;
    text-align: center;
}

nav a img{
    width: 40px;
    margin: 10px 0;
}

nav a span{
    display: block;
}

/* news */
.news{
    margin-top: 20px;

}

.news img{
    width: 100%;
}

.news a{
    float: left;
    box-sizing: border-box;
}

.news a:nth-child(1){
    width: 50%;
}

/* * .news a:nth-child(2),
.news a:nth-child(3),
{
    width: 25%;
} */ 


/* n+2 就是从从2个往后面选 */
.news a:nth-child(n+2){
    width: 25%;
    border-left: 1px solid #ccc;
}

/* .news a:nth-child(3) {
    width: 25%;
} */

js:

window.addEventListener('load', function() {
    var swiper = new Swiper('.swiper-container', {
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: {
            delay: 5000,
            disableOnInteraction: false,
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
    });
})

 

 

 HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./zy.media.min.css">
    <title>Document</title>
    <script src="./zy.media.min.js"></script>

    <style type="text/css">
        #modelView {
            background-color: #DDDDDD;
            z-index: 0;
            opacity: 0.7;
            height: 100%;
            width: 100%;
            position: relative;
        }
        
        .playvideo {
            padding-top: auto;
            z-index: 9999;
            position: relative;
            width: 300px;
            height: 200px;
        }
        
        .zy_media {
            z-index: 999999999
        }
    </style>
</head>
<body>
    <div class="playvideo">
        <div class="zy_media">
            <video data-config='{"mediaTitle": "洽洽"}' controls>
        	<source src="mov.mp4" type="video/mp4">
      	  您的浏览器不支持HTML5视频
   	 </video>

        </div>
        <div id="modelView">&nbsp;</div>
    </div>

    <script src="zy.media.min.js"></script>
    <script>
        zymedia('video', {
            autoplay: false
        });
    </script>
</body>
</html>

JS:

! function() {
    function b(a, b) { return parseInt(a.style[b] || getComputedStyle(a, null).getPropertyValue(b)) }

    function c(a, b) { return new RegExp("(\\s|^)" + b + "(\\s|$)").test(a.className) }

    function d(a, b) { a.classList ? a.classList.add(b) : c(a, b) || (a.className += "" + b) }

    function e(a, b) { a.classList ? a.classList.remove(b) : c(a, b) && (a.className = a.className.replace(new RegExp("(\\s|^)" + b + "(\\s|$)"), " ").replace(/^\s+|\s+$/g, "")) }

    function f(a, b) {
        (!isFinite(a) || 0 > a) && (a = 0); var c = b.alwaysShowHours ? [0] : []; return Math.floor(a / 3600) % 24 && c.push(Math.floor(a / 3600) % 24), c.push(Math.floor(a / 60) % 60), c.push(Math.floor(a % 60)), c = c.join(":"), 1 == b.timeFormatType && (c = c.replace(/(:|^)([0-9])(?=:|$)/g, "$10$2")), c }

    function g() { return document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen }

    function h(a) { var b, c; switch (a = a.toLowerCase().split("?")[0], b = a.substring(a.lastIndexOf(".") + 1), c = /mp4|m4v|ogg|ogv|m3u8|webm|webmv|wmv|mpeg|mov/gi.test(b) ? "video/" : "audio/", b) {
            case "mp4":
            case "m4v":
            case "m4a":
                return c + "mp4";
            case "webm":
            case "webma":
            case "webmv":
                return c + "webm";
            case "ogg":
            case "oga":
            case "ogv":
                return c + "ogg";
            case "m3u8":
                return "application/x-mpegurl";
            case "ts":
                return c + "mp2t";
            default:
                return c + b } }

    function i(a, b) { return a && !b ? h(a) : b && ~b.indexOf(";") ? b.substr(0, b.indexOf(";")) : b }

    function j(b, c, d) { var f, g, h, e = []; if (c.type)
            if ("string" == typeof c.type) e.push({ type: c.type, url: d });
            else
                for (f = 0; f < c.type.length; f++) e.push({ type: c.type[f], url: d });
        else if (null !== d) e.push({ type: i(d, b.getAttribute("type")), url: d });
        else
            for (f = 0; f < b.children.length; f++) g = b.children[f], 1 == g.nodeType && "source" == g.tagName.toLowerCase() && (d = g.getAttribute("src"), e.push({ type: i(d, g.getAttribute("type")), url: d })); if (a.features.isBustedAndroid && (b.canPlayType = function(a) { return /video\/(mp4|m4v)/i.test(a) ? "maybe" : "" }), a.features.isChromium && (b.canPlayType = function(a) { return /video\/(webm|ogv|ogg)/i.test(a) ? "maybe" : "" }), a.features.supportsCanPlayType)
            for (f = 0; f < e.length; f++)
                if ("video/m3u8" == e[f].type || "" !== b.canPlayType(e[f].type).replace(/no/, "") || "" !== b.canPlayType(e[f].type.replace(/mp3/, "mpeg")).replace(/no/, "") || "" !== b.canPlayType(e[f].type.replace(/m4a/, "mp4")).replace(/no/, "")) { h = !0; break }
        return h } var k, a = {};
    a.config = { type: "", mediaTitle: "", nativeControls: !1, autoplay: !1, preload: "none", videoWidth: "100%", videoHeight: "auto", aspectRation: 16 / 9, audioWidth: "100%", audioHeight: 44, autoLoop: !1, timeFormatType: 1, alwaysShowHours: !1, alwaysShowControls: !1, hideVideoControlsOnLoad: !1, enableFullscreen: !0, pauseOtherPlayers: !0, duration: 0, success: null, error: null },
        function(a) { var b = window.navigator.userAgent.toLowerCase(),
                c = document.createElement("video");
            a.isiOS = /iphone|ipod|ipad/i.test(b) && !window.MSStream, a.isAndroid = /android/i.test(b) && !window.MSStream, a.isBustedAndroid = /android 2\.[12]/i.test(b), a.isChromium = /chromium/i.test(b), a.hasTouch = "ontouchstart" in window, a.supportsCanPlayType = "undefined" != typeof c.canPlayType, a.isVendorBigPlay = /iphone/i.test(b) && !window.MSStream, a.isVendorControls = /baidu/i.test(b), a.isVendorFullscreen = /micromessenger|weibo/i.test(b), a.isVendorAutoplay = /v819mini/i.test(b) || a.isiOS, a.nativeFullscreenPrefix = function() { return c.requestFullScreen ? "" : c.webkitRequestFullScreen ? "webkit" : c.mozRequestFullScreen ? "moz" : c.msRequestFullScreen ? "ms" : "-" }(), a.hasOldNativeFullScreen = "-" == a.nativeFullscreenPrefix && c.webkitEnterFullscreen, a.hasOldNativeFullScreen && /mac os x 10_5/i.test(b) && (a.nativeFullscreenPrefix = "-", a.hasOldNativeFullScreen = !1) }(a.features = {}), k = 0, a.players = {}, a.MediaPlayer = function(b, c) { var e, f, g, i, d = this; if (!b.isInstantiated && (b.isInstantiated = !0, d.media = b, f = d.media.tagName.toLowerCase(), /audio|video/.test(f))) { d.isVideo = "video" === f, d.options = {}; for (e in a.config) d.options[e] = a.config[e]; try { for (e in c) d.options[e] = c[e];
                    g = JSON.parse(d.media.getAttribute("data-config")); for (e in g) d.options[e] = g[e] } catch (h) {}
                d.options.autoplay && (d.options.autoplay = !a.features.isVendorAutoplay), d.isVideo || (d.options.alwaysShowControls = !0), d.options.nativeControls || a.features.isVendorControls ? d.media.setAttribute("controls", "controls") : (i = d.media.getAttribute("src"), i = "" === i ? null : i, j(d.media, d.options, i) ? (d.id = "zym_" + k++, a.players[d.id] = d, d.init()) : alert("不支持此" + (d.isVideo ? "视" : "音") + "频")) } }, a.MediaPlayer.prototype = { isControlsVisible: !0, isFullScreen: !1, setPlayerSize: function(a) { var f, g, d = this,
                    e = b(d.container, "width");
                a > e && (d.width = e), d.enableAutoSize && (f = d.media.videoWidth, g = d.media.videoHeight, f && g && Math.abs(d.options.aspectRation - f / g) < .1 && (d.options.aspectRation = f / g), d.height = parseInt(e / d.options.aspectRation)), d.container.style.width = d.width + "px", d.media.style.height = d.container.style.height = d.height + "px" }, showControls: function() { var a = this;
                a.isControlsVisible || (a.controls.style.bottom = 0, a.options.mediaTitle && (a.title.style.top = 0), a.isControlsVisible = !0) }, hideControls: function() { var a = this;
                a.isControlsVisible && !a.options.alwaysShowControls && (a.controls.style.bottom = "-45px", a.options.mediaTitle && (a.title.style.top = "-35px"), a.isControlsVisible = !1) }, setControlsTimer: function(a) { var b = this;
                clearTimeout(b.controlsTimer), b.controlsTimer = setTimeout(function() { b.hideControls() }, a) }, updateTimeline: function(a) { var g, c = this,
                    d = void 0 !== a ? a.target : c.media,
                    e = null,
                    f = b(c.slider, "width");
                d.buffered && d.buffered.length > 0 && d.buffered.end && d.duration ? e = d.buffered.end(d.buffered.length - 1) / d.duration : void 0 !== d.bytesTotal && d.bytesTotal > 0 && void 0 !== d.bufferedBytes ? e = d.bufferedBytes / d.bytesTotal : a && a.lengthComputable && 0 !== a.total && (e = a.loaded / a.total), null !== e && (e = Math.min(1, Math.max(0, e)), c.loaded.style.width = f * e + "px", c.media.paused && setTimeout(function() { c.loaded.style.width = f * e + "px", c.updateTimeline() }, 300)), void 0 !== c.media.currentTime && c.media.duration && (g = Math.round(f * c.media.currentTime / c.media.duration), c.current.style.width = g + "px", c.handle.style.left = g - Math.round(b(c.handle, "width") / 2) + "px") }, updateTime: function() { var a = this;
                a.currentTime.innerHTML = f(a.media.currentTime, a.options), (a.options.duration > 1 || a.media.duration > 1) && (a.durationDuration.innerHTML = f(a.options.duration > 1 ? a.options.duration : a.media.duration, a.options)) }, enterFullScreen: function() { var c = this; if (c.normalHeight = b(c.container, "height"), c.normalWidth = b(c.container, "width"), "-" != a.features.nativeFullscreenPrefix) c.container[a.features.nativeFullscreenPrefix + "RequestFullScreen"]();
                else if (a.features.hasOldNativeFullScreen) return c.media.webkitEnterFullscreen(), void 0;
                d(document.documentElement, "zy_fullscreen"), c.media.style.width = c.container.style.width = "100%", c.media.style.height = c.container.style.height = "100%", d(c.fullscreenBtn, "zy_unfullscreen"), c.isFullScreen = !0 }, exitFullScreen: function() { var b = this;
                (g() || b.isFullScreen) && ("-" != a.features.nativeFullscreenPrefix ? document[a.features.nativeFullscreenPrefix + "CancelFullScreen"]() : a.features.hasOldNativeFullScreen && document.webkitExitFullscreen()), e(document.documentElement, "zy_fullscreen"), b.media.style.width = b.container.style.width = b.normalWidth + "px", b.media.style.height = b.container.style.height = b.normalHeight + "px", e(b.fullscreenBtn, "zy_unfullscreen"), b.isFullScreen = !1 }, buildContainer: function() { var a = this;
                a.container = a.media.parentNode, a.container.style.overflow = "hidden", a.container.style.height = (a.isVideo ? b(a.container, "width") / a.options.aspectRation : a.options.audioHeight) + "px", a.container.innerHTML = '<div class="zy_wrap"></div><div class="zy_controls"></div>' + (a.options.mediaTitle ? '<div class="zy_title">' + a.options.mediaTitle + "</div>" : ""), a.title = a.container.querySelector(".zy_title"), a.media.setAttribute("preload", a.options.preload), a.container.querySelector(".zy_wrap").appendChild(a.media), a.controls = a.container.querySelector(".zy_controls"), a.isVideo && (a.width = a.options.videoWidth, a.height = a.options.videoHeight, "100%" == a.width && "auto" == a.height && (a.enableAutoSize = !0), a.setPlayerSize(a.width, a.height)) }, buildPlaypause: function() {
                function c(c) {
                    (a.media.isUserClick || a.options.autoplay) && ("play" === c ? (e(b, "zy_play"), d(b, "zy_pause")) : (e(b, "zy_pause"), d(b, "zy_play"))) } var a = this,
                    b = document.createElement("div");
                b.className = "zy_playpause_btn zy_play", a.controls.appendChild(b), b.addEventListener("click", function() { a.media.isUserClick = !0, a.media.paused ? (a.media.play(), a.media.paused || a.options.alwaysShowControls || a.setControlsTimer(3e3)) : a.media.pause() }), a.media.addEventListener("play", function() { c("play") }), a.media.addEventListener("playing", function() { c("play") }), a.media.addEventListener("pause", function() { c("pse") }), a.media.addEventListener("paused", function() { c("pse") }) }, buildTimeline: function() { var e, g, h, i, j, c = this,
                    d = document.createElement("div");
                d.className = "zy_timeline", d.innerHTML = '<div class="zy_timeline_slider"><div class="zy_timeline_buffering" style="display:none"></div><div class="zy_timeline_loaded"></div><div class="zy_timeline_current"></div><div class="zy_timeline_handle"></div></div>', c.controls.appendChild(d), c.slider = d.children[0], c.buffering = c.slider.children[0], c.loaded = c.slider.children[1], c.current = c.slider.children[2], c.handle = c.slider.children[3], e = !1, g = c.slider.offsetLeft, h = b(c.slider, "width"), i = b(c.handle, "width") / 2, j = function(a) { var d, b = 0;
                    d = a.changedTouches ? a.changedTouches[0].pageX : a.pageX, c.media.duration && (g > d ? d = g : d > h + g && (d = h + g), c.handle.style.left = d - i - g + "px", b = (d - g) / h * c.media.duration, c.currentTime.innerHTML = f(c.media.currentTime, c.options), e && b !== c.media.currentTime && (c.media.currentTime = b)) }, a.features.hasTouch ? c.slider.addEventListener("touchstart", function(a) { e = !0, j(a), g = c.slider.offsetLeft, h = b(c.slider, "width"), c.slider.addEventListener("touchmove", j), c.slider.addEventListener("touchend", function() { e = !1, c.slider.removeEventListener("touchmove", j) }) }) : c.slider.addEventListener("mousedown", function(a) { e = !0, j(a), g = c.slider.offsetLeft, h = b(c.slider, "width"), c.slider.addEventListener("mousemove", j), c.slider.addEventListener("mouseup", function() { e = !1, c.slider.addEventListener("mousemove", j) }) }), c.slider.addEventListener("mouseenter", function() { c.slider.addEventListener("mousemove", j) }), c.slider.addEventListener("mouseleave", function() { e || c.slider.removeEventListener("mousemove", j) }), c.media.addEventListener("timeupdate", function(a) { c.updateTimeline(a) }) }, buildTime: function() { var a = this,
                    b = document.createElement("div");
                b.className = "zy_time", b.innerHTML = '<span class="zy_currenttime">' + f(0, a.options) + "</span>/" + '<span class="zy_duration">' + f(a.options.duration, a.options) + "</span>", a.controls.appendChild(b), a.currentTime = b.children[0], a.durationDuration = b.children[1], a.media.addEventListener("timeupdate", function() { a.updateTime() }) }, buildFullscreen: function() { var c, b = this; "-" != a.features.nativeFullscreenPrefix && (c = function() { b.isFullScreen && (g() || b.exitFullScreen()) }, document.addEventListener(a.features.nativeFullscreenPrefix + "fullscreenchange", c)), b.fullscreenBtn = document.createElement("div"), b.fullscreenBtn.className = "zy_fullscreen_btn", b.controls.appendChild(b.fullscreenBtn), b.fullscreenBtn.addEventListener("click", function() { "-" != a.features.nativeFullscreenPrefix && g() || b.isFullScreen ? b.exitFullScreen() : b.enterFullScreen() }) }, buildDec: function() { var d, e, b = this,
                    c = document.createElement("div");
                c.className = "dec_loading", c.style.display = "none", b.container.appendChild(c), d = document.createElement("div"), d.className = "dec_error", d.style.display = "none", d.innerHTML = "播放异常", b.container.appendChild(d), e = document.createElement("div"), a.features.isVendorBigPlay || (e.className = "dec_play", b.container.appendChild(e), e.addEventListener("click", function() { b.media.isUserClick = !0, b.media.play(), b.media.paused || b.options.alwaysShowControls || b.setControlsTimer(3e3) })), b.media.addEventListener("play", function() { b.media.isUserClick && (e.style.display = "none", c.style.display = "", b.buffering.style.display = "none") }), b.media.addEventListener("playing", function() { e.style.display = "none", c.style.display = "none", b.buffering.style.display = "none", d.style.display = "none" }), b.media.addEventListener("seeking", function() { c.style.display = "", e.style.display = "none", b.buffering.style.display = "" }), b.media.addEventListener("seeked", function() { c.style.display = "none", b.buffering.style.display = "none" }), b.media.addEventListener("pause", function() { e.style.display = "" }), b.media.addEventListener("waiting", function() { c.style.display = "", e.style.display = "none", b.buffering.style.display = "" }), b.media.addEventListener("error", function(a) { c.style.display = "none", e.style.display = "", b.buffering.style.display = "none", b.media.pause(), d.style.display = "", "function" == typeof b.options.error && b.options.error(a) }) }, init: function() { var d, b = this,
                    c = ["Container", "Playpause", "Timeline", "Time"]; for (b.options.enableFullscreen && !a.features.isVendorFullscreen && b.isVideo && c.push("Fullscreen"), b.isVideo && c.push("Dec"), d = 0; d < c.length; d++) try { b["build" + c[d]]() } catch (e) {}
                b.isVideo && (a.features.hasTouch ? b.media.addEventListener("click", function() { b.isControlsVisible ? b.hideControls() : (b.showControls(), b.media.paused || b.options.alwaysShowControls || b.setControlsTimer(3e3)) }) : (b.media.addEventListener("click", function() { b.media.paused ? b.media.play() : b.media.pause() }), b.container.addEventListener("mouseenter", function() { b.showControls(), b.options.alwaysShowControls || b.setControlsTimer(3e3) }), b.container.addEventListener("mousemove", function() { b.showControls(), b.options.alwaysShowControls || b.setControlsTimer(3e3) })), b.options.hideVideoControlsOnLoad && b.hideControls(), b.media.addEventListener("loadedmetadata", function() { b.enableAutoSize && setTimeout(function() { isNaN(b.media.videoHeight) || b.setPlayerSize() }, 50) })), b.media.addEventListener("play", function() { var c, d; for (d in a.players)
                        if (c = a.players[d], c.id != b.id && b.options.pauseOtherPlayers && !c.paused && !c.ended) try { c.media.pause() } catch (e) {} }), window.addEventListener("orientationchange", function() { setTimeout(function() { b.setPlayerSize() }, 500) }), b.media.addEventListener("ended", function(a) { b.media.currentTime = 0, b.options.autoLoop ? b.media.play() : (b.isVideo && setTimeout(function() { b.container.querySelector(".dec_loading").style.display = "none" }, 20), b.media.pause()), b.updateTimeline(a) }), b.media.addEventListener("loadedmetadata", function() { b.updateTime() }), b.options.autoplay && (b.media.isUserClick = !1, b.media.play()), "function" == typeof b.options.success && b.options.success(b.media) } }, window.zymedia = function(b, c) { "string" == typeof b ? [].forEach.call(document.querySelectorAll(b), function(b) { new a.MediaPlayer(b, c) }) : new a.MediaPlayer(b, c) } }();

 

 

 BootStrap 轮播图

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
    <script src="./bootstrap/js/jquery.min.js"></script>
    <script src="./bootstrap/js/bootstrap.min.js"></script>
    <style>
        .focus{
            width: 700px;
            height: 320px;
            background-color: blue;
            margin:  100px auto ;
        }
        .carousel,
        .carousel img{
            width: 100%;
            height: 320px !important;
            /* background-size: auto; */

        }
    </style>
</head>
<body>
    <div class="focus">
        <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="./images/40.jpg" alt="...">
                <div class="carousel-caption">
                 王俊凯
                </div>
              </div>
              <div class="item">
                <img src="./images/5.jpg" alt="...">
                <div class="carousel-caption">
                  易烊千玺
                </div>
              </div>
              <div class="item">
                <img src="./images/22.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" 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>
    </div>

    <script>
        $('.carousel').carousel({
            interval: 2000
            })
    </script>
</body>
</html>

 

 

 

 阿里百秀轮播图

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- 引入bootstrap 样式文件 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- 引入我们自己的首页样式文件 -->
    <link rel="stylesheet" href="css/index.css">
    <!-- 先引入jquery js文件 -->
    <script src="bootstrap/js/jquery.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <title>Document</title>
</head>

<body>
    <div class="container">
        <div class="row">
            <header class="col-md-2">
                <div class="logo">
                    <a href="#">
                        <img src="images/logo.png" alt="" class="hidden-xs">
                        <span class="visible-xs">阿里百秀</span>
                    </a>
                </div>
                <div class="nav">
                    <ul>
                        <li><a href="#" class="glyphicon glyphicon-camera">生活馆</a></li>
                        <li><a href="#" class="glyphicon glyphicon-picture">自然汇</a></li>
                        <li><a href="#" class="glyphicon glyphicon-phone">科技湖</a></li>
                        <li><a href="#" class="glyphicon glyphicon-gift">奇趣事</a></li>
                        <li><a href="#" class="glyphicon glyphicon-glass">美食杰</a></li>
                    </ul>
                </div>
            </header>
            <article class="col-md-7">
                <!-- 新闻 -->
                <div class="news clearfix">
                    <ul>
                        <li>
                            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">


                                <!-- Wrapper for slides -->
                                <div class="carousel-inner" role="listbox">
                                    <div class="item active">
                                        <img src="upload/banner.dpg" alt="...">
                                        <div class="carousel-caption">
                                            阿里百秀1
                                        </div>
                                    </div>
                                    <div class="item">
                                        <img src="upload/banner1.dpg" alt="...">
                                        <div class="carousel-caption">
                                            阿里百秀2
                                        </div>
                                    </div>
                                    <div class="item">
                                        <img src="upload/banner2.dpg" alt="...">
                                        <div class="carousel-caption">
                                            阿里百秀3
                                        </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>
                            <script>
                                $('.carousel').carousel({
                                    interval: 2000
                                })
                            </script>
                        </li>
                        <li>
                            <a href="#">
                                <img src="upload/10.jpg" alt="">
                                <p>奇了 成都一小区护卫长得像马云 市民纷纷求合影</p>
                            </a>
                        </li>

                        <li>
                            <a href="#">
                                <img src="upload/21.jpg" alt="">
                                <p>奇了 成都一小区护卫长得像马云 市民纷纷求合影</p>
                            </a>
                        </li>

                        <li>
                            <a href="#">
                                <img src="upload/22.jpg" alt="">
                                <p>奇了 成都一小区护卫长得像马云 市民纷纷求合影</p>
                            </a>
                        </li>

                        <li>
                            <a href="#">
                                <img src="upload/24.jpg" alt="">
                                <p>奇了 成都一小区护卫长得像马云 市民纷纷求合影</p>
                            </a>
                        </li>

                    </ul>
                </div>
                <!-- 发表 -->
                <div class="publish">
                    <div class="row">
                        <div class="col-sm-9">
                            <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3>
                            <p class="text-muted hidden-xs">alibaixiu 发布于 2015-11-23</p>
                            <p class="hidden-xs">指甲是经常容易被人们忽略的身体部位, 事实上从指甲的健康状况可以看出一个人的身体健康状况, 快来看看10个暗藏在指甲里知识吧!</p>
                            <p class="text-muted">阅读(2417)评论(1)赞 (18) <span class="hidden-xs">标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span>

                            </p>
                        </div>
                        <div class="col-sm-3 pic hidden-xs">
                            <img src="upload/40.jpg" alt="">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-9">
                            <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3>
                            <p class="text-muted hidden-xs">alibaixiu 发布于 2015-11-23</p>
                            <p class="hidden-xs">指甲是经常容易被人们忽略的身体部位, 事实上从指甲的健康状况可以看出一个人的身体健康状况, 快来看看10个暗藏在指甲里知识吧!</p>
                            <p class="text-muted">阅读(2417)评论(1)赞 (18) <span class="hidden-xs">标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span>

                            </p>
                        </div>
                        <div class="col-sm-3 pic hidden-xs">
                            <img src="upload/5.jpg" alt="">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-9">
                            <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3>
                            <p class="text-muted hidden-xs">alibaixiu 发布于 2015-11-23</p>
                            <p class="hidden-xs">指甲是经常容易被人们忽略的身体部位, 事实上从指甲的健康状况可以看出一个人的身体健康状况, 快来看看10个暗藏在指甲里知识吧!</p>
                            <p class="text-muted">阅读(2417)评论(1)赞 (18) <span class="hidden-xs">标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span>

                            </p>
                        </div>
                        <div class="col-sm-3 pic hidden-xs">
                            <img src="upload/40.jpg" alt="">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-9">
                            <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3>
                            <p class="text-muted hidden-xs">alibaixiu 发布于 2015-11-23</p>
                            <p class="hidden-xs">指甲是经常容易被人们忽略的身体部位, 事实上从指甲的健康状况可以看出一个人的身体健康状况, 快来看看10个暗藏在指甲里知识吧!</p>
                            <p class="text-muted">阅读(2417)评论(1)赞 (18) <span class="hidden-xs">标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span>

                            </p>
                        </div>
                        <div class="col-sm-3 pic hidden-xs">
                            <img src="upload/24.jpg" alt="">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-9">
                            <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3>
                            <p class="text-muted hidden-xs">alibaixiu 发布于 2015-11-23</p>
                            <p class="hidden-xs">指甲是经常容易被人们忽略的身体部位, 事实上从指甲的健康状况可以看出一个人的身体健康状况, 快来看看10个暗藏在指甲里知识吧!</p>
                            <p class="text-muted">阅读(2417)评论(1)赞 (18) <span class="hidden-xs">标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span>

                            </p>
                        </div>
                        <div class="col-sm-3 pic hidden-xs">
                            <img src="upload/22.jpg" alt="">
                        </div>
                    </div>
                </div>

            </article>
            <aside class="col-md-3">
                <a href="#" class="banner">
                    <img src="upload/zgboke.jpg" alt="">
                </a>
                <a href="#" class="hot">
                    <span class="btn btn-primary">热搜</span>
                    <h4 class="text-primary">欢迎加入中国博客联盟</h4>
                    <p>这里收录国内各个领域的优秀博客,是一个全人工编辑的开放式博客联盟交流和展示平台......</p>
                </a>
            </aside>
        </div>
    </div>
</body>

</html>

CSS:

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}

a {
    color: #666;
    text-decoration: none;
}

a:hover {
    text-decoration: none;
}

body {
    background-color: #f5f5f5;
}

.container {
    background-color: #fff;
}


/* 修改container的最大宽度为 1280 根据设计稿来走的 */

@media screen and (min-width: 1280px) {
    .container {
        width: 1280px;
    }
}


/* header */

header {
    padding-left: 0!important;
}

.logo {
    background-color: #429ad9;
}

.logo img {
    display: block;
    /* width: 100%; */
    /* logo图片不需要缩放 */
    max-width: 100%;
    margin: 0 auto;
}


/* 1.我们如果进入了超小屏幕下  logo里面的图片就隐藏起来 */


/* 2. 我们事先准备好一个盒子 在logo里面,它平时是隐藏起来的,只有在超小屏幕下显示 */

.logo span {
    display: block;
    height: 50px;
    line-height: 50px;
    color: #fff;
    font-size: 18px;
    text-align: center;
}

.nav {
    background-color: #eee;
    border-bottom: 1px solid #ccc;
}

.nav a {
    display: block;
    height: 50px;
    line-height: 50px;
    padding-left: 30px;
    font-size: 16px;
}

.nav a:hover {
    background-color: #fff;
    color: #333;
}

.nav a::before {
    vertical-align: middle;
    padding-right: 5px;
}


/* 当我们进入 小屏幕 还有 超小屏幕的时候 我们 nav 里面的li 浮动起来 并且宽度为 20%  */

@media screen and (max-width: 991px) {
    .nav li {
        float: left;
        width: 20%;
    }
    article {
        margin-top: 10px;
    }
}


/* 当我们进入 超小屏幕的时候 我们 nav 文字会变成14px  */

@media screen and (max-width: 767px) {
    .nav li a {
        font-size: 14px;
        padding-left: 3px;
    }
    /* 当我们处于超小屏幕 news 第一个li 宽度为 100%  剩下的小li  各 50% */
    .news li:nth-child(1) {
        width: 100%!important;
    }
    .news li {
        width: 50%!important;
    }
    .publish h3 {
        font-size: 14px;
    }
}

.news li>a {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

.news li {
    float: left;
    width: 25%;
    height: 128px;
    padding-right: 10px;
    margin-bottom: 10px;
}

.news li:nth-child(1) {
    width: 50%;
    height: 266px;
}

.carousel,
.carousel img {
    width: 100%;
    height: 266px!important;
}

.news li:nth-child(1) p {
    line-height: 41px;
    font-size: 20px;
    padding: 0 10px;
}

.news li a img {
    width: 100%;
    height: 100%;
}

.carousel-caption {
    line-height: 41px;
    font-size: 16px!important;
    padding: 0!important;
}

.news li a p,
.carousel-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 41px;
    padding: 5px 10px;
    margin-bottom: 0;
    background: rgba(0, 0, 0, .5);
    font-size: 12px;
    color: #fff;
}

.publish {
    border-top: 1px solid #ccc;
}

.publish .row {
    border-bottom: 1px solid #ccc;
    padding: 10px 0;
}

.pic {
    margin-top: 10px;
}

.pic img {
    width: 100%;
}

.banner img {
    width: 100%;
}

.hot {
    display: block;
    margin-top: 20px;
    padding: 0 20px 20px;
    border: 1px solid #ccc;
}

.hot span {
    border-radius: 0;
    margin-bottom: 20px;
}

.hot p {
    font-size: 12px;
}

 

 

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <button class="set">存储数据</button>
    <button class="get">获取数据</button>
    <button class="remove">删除数据</button>
    <button class="del">清空所有数据</button>


    <script>
        var ipt = document.querySelector('input');
        var set = document.querySelector('.set');
        var get = document.querySelector('.get');
        var remove= document.querySelector('.remove');
        var del = document.querySelector('.del');
        set.addEventListener('click',function(){
            //当点击了之后,就可以把表单里面的值存储起来
            var val = ipt.value;
            sessionStorage.setItem('uname',val);
            sessionStorage.setItem('pwd',val);
           
        });


      get.addEventListener('click',function(){
            //当点击了之后,就可以把表单里面的值获取起来 
        console.log(sessionStorage.getItem('uname'));
        });

        remove.addEventListener('click',function(){
            //当点击了之后,就可以把表单里面的值删除
            sessionStorage.removeItem('uname');
        });


        del.addEventListener('click',function(){
            //当点击了之后,就可以把表单里面的值全部清除
            sessionStorage.clear();
        });


    </script>
</body>
</html>

 

 

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <button class="set">存储数据</button>
    <button class="get">获取数据</button>
    <button class="remove">删除数据</button>
    <button class="del">清空所有数据</button>


    <script>
        
        var ipt = document.querySelector('input');
        var set = document.querySelector('.set');
        var get = document.querySelector('.get');
        var remove= document.querySelector('.remove');
        var del = document.querySelector('.del');
        set.addEventListener('click',function(){
            //当点击了之后,就可以把表单里面的值存储起来
            var val = ipt.value;
            localStorage.setItem('username',val);
            localStorage.setItem('pwd',val);
           
        });


      get.addEventListener('click',function(){
            //当点击了之后,就可以把表单里面的值获取起来 
        console.log(localStorage.getItem('username'));
        });

        remove.addEventListener('click',function(){
            //当点击了之后,就可以把表单里面的值删除
            localStorage.removeItem('username');
        });


        del.addEventListener('click',function(){
            //当点击了之后,就可以把表单里面的值全部清除
            localStorage.clear();
        });


    </script>
</body>
</html>

 案例:

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="username"> <input type="checkbox" name="" id="remember"> 记住用户名

    <script>
        var username = document.querySelector('#username');
        var  remember = document.querySelector('#remember');
        if(localStorage.getItem('username')){
            username.value=localStorage.getItem('username');
            remember.checked=true;
        }
        remember.addEventListener('change',function(){
            if(this.checked){
                localStorage.setItem('username');
            } else{
                localStorage.removeItem('username');

            }
        })
    </script>
</body>
</html>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值