美文网首页
如何使用雪碧图

如何使用雪碧图

作者: Transnet2014 | 来源:发表于2017-04-19 18:54 被阅读77次

返回导航

#154

CSS3, font icons, svg
Yes! CSS3, font icons, svg are great tools! But unfortunately there are some layouts and solutions we need to compress to reduce the number of requests.

There are some approaches to figure out this issue easily.

Using gulp spritesmith.
Using compass sprite.

We could include both in a option. If the user select to use sass, ask for compass and include the task. if the user select other css preprocessor, we could ask for include spritesmith.

I've been using spritesmith + imagemin + csso in production and works pretty good!

A simple example:

gulp.task('sprite', function () {
    var spritesmith = require('gulp.spritesmith');
    var imagemin = require('gulp-imagemin');
    var csso = require('gulp-csso');
    var del = require('del');
    // Generate our spritesheet
    del(['app/css/*_sprite.png'], function (err) {
        var spriteData = gulp.src('src/images/**/*.png').pipe(spritesmith({
            imgName: new Date().getTime()+'_sprite.png',
            cssName: 'sprite.css'
        }));
        // Pipe image stream through image optimizer and onto disk
        spriteData.img
            .pipe(imagemin())
            .pipe(gulp.dest('app/css/'));

        // Pipe CSS stream through CSS optimizer and onto disk
        spriteData.css
            .pipe(csso())
            .pipe(gulp.dest('src/css/'));
    });
});

返回导航

相关文章

  • CSS 雪碧图

    Question: 1、什么是雪碧图?2、为什么使用雪碧图?3、什么情况下适合使用雪碧图?4、雪碧图怎么使用?5、...

  • css-Sprite (雪碧图)

    雪碧图的使用场景: 不推荐使用雪碧图的地方: css Sprite(雪碧图)的实现原理: 雪碧图的实现方式: 作者...

  • 如何使用雪碧图

    返回导航 #154 CSS3, font icons, svgYes! CSS3, font icons, svg...

  • Python使用png图片生成MapboxGL雪碧图

    在mapboxgl中,使用sprite雪碧图实现图标渲染是比较常见的方式。对于自己制作定义的图标如何生成雪碧图,本...

  • 前端—雪碧图

    使用雪碧图的优点有以下几点: 雪碧图的制作与使用方法:

  • webpack中如何使用雪碧图

    一、什么是雪碧图? CSS雪碧 即CSS Sprite,也有人叫它CSS精灵,是一种CSS图像合并技术,该方法是将...

  • css源码笔记(六)【爱创课堂专业前端培训】

    复习: 雪碧图使用: PS切图à应用 雪碧图又叫CSSSprite或CSS精灵 将页面中碎小的图片集中在一张比较大...

  • css-雪碧图

    雪碧图 雪碧图是图片拼接技术,主要用来减少http请求。 制作 ps 自己制作 使用工具,在windows有CSS...

  • 雪碧图的使用

    CSS Sprites技术被国内一些人称为CSS雪碧图,其实就是把网页中一些背景图片整合到一张图片文件中,再利用C...

  • 基于nodejs的雪碧图制作工具

    前颜(yan) 雪碧图(CSS sprite ),就是把很多小图标合并为一张图片。 在Web开发中,使用雪碧图是优...

网友评论

      本文标题:如何使用雪碧图

      本文链接:https://www.haomeiwen.com/subject/gvphzttx.html