css - CSS 源映射中的换行符

标签 css google-chrome less

我有一些 LESS,它的格式是选择器之间有空格,大括号在新行上。

body {
    background-color: #3a3a3a;
    font-family:Verdana;
}

header
{
    background-color: rgba(40, 40, 40, 0.7);
    position: relative;
    z-index: 100; 
}

#companyLogo
{
    margin-top:15px;
    margin-bottom:10px; 
    margin-left:10px; 
}

当您通过 chrome 调试器查看 less 时,它会以不同的间距出现,这会导致行号偏离。

body {
  background-color: #3a3a3a;
  font-family: Verdana;
}
header {
  background-color: rgba(40, 40, 40, 0.7);
  position: relative;
  z-index: 100;
}
#companyLogo {
  margin-top: 15px;
  margin-bottom: 10px;
  margin-left: 10px;
}

这是我用来构建 less 的 Gruntfile.js

module.exports = function (grunt) {
    grunt.initConfig({
        watch: {
            less: {
                files: ["css/*.less"],
                tasks: ["less"],
                options: {
                    livereload: true,
                }
            }
        },
        less: {
            development: {
                options: {
                    sourceMap: true,
                    //sourceMapFileInline: true,
                    sourceMapBasepath: "css/",
                    sourceMapURL: "style.css.map",
                    sourceMapFilename: "css/style.css.map"
                },
                files: {
                    "css/style.css": "css/style.less"
                }
            },
            compressed:
            {
                options: {
                    sourceMap: true,
                    //sourceMapFileInline: true,
                    compress: true,
                    sourceMapBasepath: "css/",
                    sourceMapURL: "style.min.css.map",
                    sourceMapFilename: "css/style.min.css.map"
                },
                files: {
                    "css/style.min.css": "css/style.less"
                }
            }
        }
    });

    // The following line loads the grunt plugins.
    grunt.loadNpmTasks("grunt-contrib-less");
    grunt.loadNpmTasks("grunt-contrib-watch");
};

有什么办法解决这个问题吗?

在 CSS 中工作时必须在选择器上查找而不是直接找到一行,这很糟糕。

最佳答案

我现在要采用的解决方案是格式化 less 以匹配 chrome 期望在与选择器位于同一行的左大括号。

关于css - CSS 源映射中的换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30469676/

相关文章:

html - 在小型设备上停止下一行的图像

javascript - 如何对齐 CSS 我的输入和标签

html - Chrome 中的 Media print.css 不打印 html 内容

performance - 如何读取 Chrome DevTools 中的网络选项卡 - 加载时间

javascript - Node.js Express/less-middleware & Bootstrap 3

css - 如何在 less 中创建列表输出?

jquery - 替代 fadeOut() 以创建脉冲效果

javascript - CSS div 以绝对定位的内容拉伸(stretch)

css - @import less file inside another less 不起作用

javascript - 使用后退按钮时停止服务人员表单重新提交表单