I use gulp-spritesmith
to create my sprite and I run into a problem: I want some of the generated styles to be properties for hover rules, not class selectors. Adding a class to the mouseover event looks ugly, and I don't see it as a solution.
For example:
.icon-sr_ext_icon_right {
background-image: url(/imgs/static/external_sprite.png);
background-position: -300px -100px;
width: 50px;
height: 50px;
}
.icon-sr_ext_icon_right_hovered {
background-image: url(/imgs/static/external_sprite.png);
background-position: -222px -200px;
width: 50px;
height: 50px;
}
To be:
.icon-sr_ext_icon_right {
background-image: url(/imgs/static/external_sprite.png);
background-position: -300px -100px;
width: 50px;
height: 50px;
}
.icon-sr_ext_icon_right:hover{
background-image: url(/imgs/static/external_sprite.png);
background-position: -222px -200px;
width: 50px;
height: 50px;
}
Here is my gulp task code:
gulp.task('external_sprite', function() {
var spriteData =
gulp.src(paths.external.sprite)
.pipe(plugins.debug( { title: "Processing image for external sprite:" } ) )
.pipe(plugins.spritesmith({
imgName: 'external_sprite.png',
imgPath: '/imgs/static/external_sprite.png',
cssName: 'external_sprite.css'
}));
spriteData.img.pipe(gulp.dest('./www/imgs/static/'));
spriteData.css.pipe(gulp.dest('./' + paths.external.src));
});
source
share