Closed davidmatas closed 10 years ago
Selectors for the css
template can be defined via cssOpts.cssClass
. For adding hover to all selectors, this can be done with:
cssOpts: {
cssClass: function (item) {
// Name CSS selector `.sprite-home:hover` for `home.png`
return '.sprite-' + item.name + ':hover';
}
}
Hi Todd,
I'm using the version 4.6.1 and I have the following task in the Gruntfile.js
sprite: {
icons: {
src: 'styles/img/sprites/icons/*.png',
dest: 'styles/img/icons.png',
destCss: 'styles/css/icons.css',
cssTemplate: 'styles/img/sprites/sprite.mustache',
cssOpts: {
cssClass: function (item) {
return '.sprite-' + item.name + ':hover';
}
}
}
},
but still does not see the hover state in the resulted css. Can you please clarify what I'm doing wrong.
Thank you!
@yuyokk There are a few things wrong with your setup:
3.0.0
, cssClass
has been renamed to cssSelector
to be more generic
cssSelector
is used by the normal CSS template so your cssOpts
are currently in vain.
To remedy your issue, the clearest options are:
cssTemplate
)sprite: {
icons: {
src: 'styles/img/sprites/icons/*.png',
dest: 'styles/img/icons.png',
destCss: 'styles/css/icons.css',
cssOpts: {
cssClass: function (item) {
return '.sprite-' + item.name + ':hover';
}
}
}
},
:hover
classes
cssOpts
as this is no longer used@twolfson
this solution works for me.
Stop using a custom CSS template
Thank you for the reply. I appreciate it!
Thank, useful feature
Is there a way to generate
:hover
styles from the name of the image?