1 | <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | body { font-size: 1.6rem; background: #f7f7f7; } @media only screen and (max-width: 50em) { body { font-size: 1.2rem; background: #fff; } } @media only screen and (min-width: 30.0625em) and (max-width:50em){ } @media only screen and (max-width: 30em) { body { font-size: 1.0rem; background: #999; } } |
1 2 3 4 | <!--[if lt IE 9]> <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script> <![endif]--> |
1 2 3 4 5 6 | html { font-size: 62.5%; /* 10÷16=62.5% */ } body { font-size:1.2rem ; /* 12÷10=1.2 */ } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Owlcarousel2/ ├── assets/ │ ├── owl.carousel.css │ ├── owl.carousel.min.css // 主样式文件 │ ├── owl.theme.default.css │ ├── owl.theme.default.min.css // 皮肤样式文件 │ ├── owl.theme.green.css │ ├── owl.theme.green.min.css │ └── owl.video.play.png │ ├── owl.carousel.js ├── owl.carousel.min.js ├── LICENSE-MIT └── README.md |
1 2 3 4 5 6 7 8 9 10 11 12 13 | <div class="ad"> <div class="owl-carousel owl-theme"> <div class="item"> <img src="img/ad001.png" alt=""> // 图片尺寸480*480 </div> <div class="item"> <img src="img/ad002.png" alt=""> </div> <div class="item"> <img src="img/ad003.png" alt=""> </div> </div> </div> |
1 2 | <link rel="stylesheet" href="OwlCarousel2/assets/owl.carousel.min.css"> <link rel="stylesheet" href="OwlCarousel2/assets/owl.theme.default.min.css"> |
1 2 3 | <script src="js/jquery-3.2.1.min.js"></script> <script src="OwlCarousel2/owl.carousel.min.js"></script> <script src="js/main.js"></script> |
1 2 3 4 5 6 7 8 9 | $(document).ready(function(){ $(".owl-carousel").owlCarousel({ items: 1, // 一屏看到的图片数量 loop: true, // 循环滚动 autoplay: true, // 自动播放 autoplayTimeout: 3000, // 时间间隔 autoplayHoverPause: true //鼠标放在图片上暂停滚动 }); }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | $(function(){ function makeImageResponsive(){ var img = $('.cotent img'); var width = $(window).width(); if(width <= 480){ img.attr('src', '480.png'); }else if(width <= 800){ img.attr('src', '800.png'); }else{ img.attr('src', '1600.png'); } } $(window).on('resize load', makeImageResponsive); }) |
1 | <img src="img/480.png" srcset="img/480.png 480w,img/800.png 800w, img/1600.png 1600w alt=""> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <div class="owl-carousel owl-theme"> <div class="item"> <picture> <source srcset="img/ad001-l.png" media="(min-width: 50em)"> <source srcset="img/ad001-m.png" media="(min-width: 30em)"> <img srcset="img/ad001.png" alt=""> </picture> </div> <div class="item"> <picture> <source srcset="img/ad002-l.png" media="(min-width: 50em)"> <source srcset="img/ad002-m.png" media="(min-width: 30em)"> <img srcset="img/ad002.png" alt=""> </picture> </div> <div class="item"> <picture> <source srcset="img/ad003-l.png" media="(min-width: 50em)"> <source srcset="img/ad003-m.png" media="(min-width: 30em)"> <img srcset="img/ad003.png" alt=""> </picture> </div> </div> <!-- 在 body 末尾引入--> <script src="js/vendor/picturefill.min.js"></script> |
1 | $ npm install --save-dev gulp |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | var gulp = require('gulp'); var rev = require('gulp-rev'); var revReplace = require('gulp-rev-replace'); var useref = require('gulp-useref'); var filter = require('gulp-filter'); var uglify = require('gulp-uglify'); var csso = require('gulp-csso'); gulp.task('default', function() { var jsFilter = filter('**/*.js', {restore: true}); var cssFilter = filter('**/*.css', {restore: true}); var indexHtmlFilter = filter(['**/*', '!**/index.html'], {restore: true}); return gulp.src('src/index.html') .pipe(useref()) .pipe(jsFilter) .pipe(uglify()) .pipe(jsFilter.restore) .pipe(cssFilter) .pipe(csso()) .pipe(cssFilter.restore) .pipe(indexHtmlFilter) .pipe(rev()) .pipe(indexHtmlFilter.restore) .pipe(revReplace()) .pipe(gulp.dest('dist')); }); |
1 | $ npm install gulp gulp-rev gulp-rev-replace gulp-useref gulp-filter gulp-filter gulp-uglify gulp-csso --save-dev |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <!-- build:css css/combined.css --> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="js/vendor/OwlCarousel2/assets/owl.carousel.min.css"> <link rel="stylesheet" href="js/vendor/OwlCarousel2/assets/owl.theme.default.min.css"> <link rel="stylesheet" href="css/main.css"> <!-- endbuild --> <!-- build:js js/combined.js --> <script src="js/jquery-3.2.1.min.js"></script> <script src="js/vendor/OwlCarousel2/owl.carousel.min.js"></script> <script src="js/vendor/picturefill.min.js"></script> <script src="js/main.js"></script> <!-- endbuild --> |
1 | $ gulp |
1 2 3 4 5 6 7 8 | dist/ ├── css/ │ ├──combined-3f8e363e08.css // 打包合并后的css文件 │ └──combined-56ca943019.css ├── img/ ├── js/ │ └── combined-7762fa2c22.js // 打包合并后的js文件 └── index.html |
欢迎光临 吾爱编程 (http://www.52pg.net/) | Powered by Discuz! X3.2 |