html - Gulp Uncss 破坏了 Bootstrap 下拉导航栏导航

标签 html css wordpress twitter-bootstrap uncss

我想在我的一个大 css 文件上使用 uncss,但这样做会破坏我的 Bootstrap 导航的下拉菜单。

这是工作部分:http://metalotechnika.com

这是我使用 uncss 的部分:http://metalotechnika.horyzon.de .

您会注意到下拉菜单不起作用。它使用 Twitter Bootstrap 导航栏。

我的 gulpfile 部分如下所示:

gulp.task('uncss', function() {
    return gulp.src('style.css')
        .pipe(uncss({
            html: ['uncss/uncss.html']
        }))
        .pipe(gulp.dest(''));
});

即使我在这里选择一个 URL,它也会中断。我暂时禁用了生产站点上的缓存和 css 压缩,这样您就可以看到 style.css 中的重要区别,也就是获得“uncss”。

如何使用 uncss 减少我的 css?为什么它会损坏,我该如何解决?

最佳答案

将菜单使用的类添加到忽略列表如下所示:

gulp.task('uncss', function() {
return gulp.src('style.css')
    .pipe(uncss({
        html: ['uncss/uncss.html'],
        ignore: [
            ".fade",
            ".fade.in",
            ".collapse",
            ".collapse.in",
            ".collapsing",
            /\.open/
       ]
    }))
    .pipe(gulp.dest(''));

});

来自这个线程:https://github.com/giakki/uncss/issues/64

您可以根据需要在列表中添加或删除类。

关于html - Gulp Uncss 破坏了 Bootstrap 下拉导航栏导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28082782/

相关文章:

css - 最小高度不适用于另一台服务器。

html - 页脚不在页面底部

html - CSS 样式不影响 PHP 中的段落

javascript - 如何使用 JavaScript 和 HTML 从 REST API 选择特定数据

javascript - 类似俄罗斯方 block 的游戏中的硬掉落件

css - 试图弄清楚为什么一个图像在容器外缩放

javascript - 用于制作自定义选项卡的最简单的 javascript 库?

javascript - 如何使用ajax(WordPress)添加加载更多以获取自定义查询数据?

php - 如何从 PHP 函数中返回 MySQL 字符串?

javascript - 如何阻止 jQuery .load() 函数多次触发?