- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 gulp-spritesmith
生成我的 Sprite ,我遇到了一个问题:我希望一些生成的样式成为悬停规则的属性,而不是类选择器的属性。在鼠标悬停事件上添加类看起来很难看,我认为这不是解决方案。
例如:
.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;
}
成为:
.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;
}
这是我的 gulp 任务代码:
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));
});
最佳答案
我找到了一种使用 sass
技术自动创建悬停效果样式的方法。简单地,生成 sprite,然后将生成的 css 导入另一个 sass 文件并扩展所需的类:
@import 'external_sprite';
.icon-sr_ext_icon_right:hover {
@extend .icon-sr_ext_icon_right_hovered;
}
插件的主要贡献者在 issue on github 中建议了另一种方法.这个想法是使用cssOpts.cssClass
:
cssOpts: {
cssSelector: function (item) {
// If this is a hover sprite, name it as a hover one (e.g. 'home-hover' -> 'home:hover')
if (item.name.indexOf('-hover') !== -1) {
return '.sprite-' + item.name.replace('-hover', ':hover');
// Otherwise, use the name as the selector (e.g. 'home' -> 'home')
} else {
return '.sprite-' + item.name;
}
}
}
但是如果您正在设置样式文件的 .scss
扩展名,则此解决方案不起作用。
关于javascript - 借助 :hover rule instead of a class selector 的 gulp-spritesmith 属性生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33171296/
XmlTextReader 提供对 XML 数据流的只进只读访问。当前节点指读取器定位到的节点。使用任何读方法推进读取器并且属性反映当前节点的值。 此类实现 XmlReader 并符合 W3C 可扩
我需要在我的代码中调用一些java代码。我使用 BeanShell 来实现。所以,我可以这样做: public void testInterpreter() { Interpreter i =
嗨,我对 MySQL 相当陌生,我遇到了一个无法解决的问题。我有一个表“option_benefits_id”。 id | option_id | benefit_id ===============
我有一个很大的位图,当 qwerty 键盘可见时,我想将其保存在内存中。我的应用程序始终处于横向状态,因此这是唯一会导致重绘的配置更改。我听说这就是 onRetainNonConfigurationi
我正在尝试匹配以下字符串: something, something, something, something, something shouldignore 所需的输出为:[something,
我正在尝试借助对话框添加新客户端,但我的编辑文本似乎不存在。 看起来所有 ID 都是正确的,并且 Activity 生命周期一切都很好,但我得到: java.lang.NullPointerExcep
我有 2 个如下所示的列表。 List list1 = Arrays.asList("I'm a cat", "dog", "There's an elephant and I'm seeing",
在模板编程中,static_assert 帮助程序员检查模板参数的约束并在违反约束时生成人类可读错误消息。 考虑这段代码, template void f(T) { static_assert
我花了过去 6 个小时试图解决这个问题,但我找到的关于 Knockout.js 中的订阅如何工作的文档非常少,以至于它现在已经从“有点烦人”类别转移到“彻头彻尾令人沮丧”类别。 我想要实现什么目标?
您好,我正在尝试在“varags”和“增强型 for 循环”的帮助下进行加法。但是我得到了这个标记“此方法必须返回 int 类型的结果”。 class Hello1 { int pluss(int..
我想将 css 保存在 css 文件中,由 jquery 完成更改?例如。我想用 CSS 方法更改背景颜色并一直保存该背景颜色。 如果有人有其他方法可以做到这一点。请分享。基本上我想这样做,如果 Do
我需要使用 NLP 解决以下问题,你能给我一些关于如何使用 OpenNLP API 实现这个的指示吗 一个。如何判断一个句子是否暗示过去、现在或将来的某个 Action 。 (e.g.) I was
我在二叉树的帮助下构建了一棵树来评估包含一元和二元运算符、常量和变量的数学表达式。 但我现在面临如何可视化如何表示三元运算的问题?可以通过二叉树来完成吗?如果不是,我是否有更好的数据结构来表示和评估相
我想根据搜索栏的运动放大和缩小图像! !任何人都可以帮助我做到这一点,请您及时回复,我们将不胜感激! ! ! 最佳答案 onProgressChanged() 方法做我想做的事! ! 公共(publi
借助 Flurry 分析,我已将移动分析集成到我的 iPhone 应用程序中,但我无法跟踪页面浏览量。 我在我的 Application Delegate 中使用了以下代码,并在 navigation
如何借助 javascript 发送 http header ? 最佳答案 当然。 var xhr = new XMLHttpRequest(); xhr.open("POST", "/path/to
我们正在连接到远程机器,然后将 .log 文件检索到本地以查看日志。但是有没有一种方法可以让我在浏览器中使用 ULR,这样当日志内容被记录到文件中时,日志就会显示为 。 谢谢,拉杰什 最佳答案 Tom
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit th
我有一堆 需要向左浮动的节点。这些节点向左浮动时的宽度总和大于其父容器。 不是增加父节点的宽度,而是扩大父级的高度并基本上向下流动到下一行。 这个问题是否有 CSS 解决方案,或者我是否需要一个 j
脚本 1 #!/usr/local/bin/expect spawn sftp user@10.xx.xxx.xx expect \"password\" send \"pass\r\" intera
我是一名优秀的程序员,十分优秀!