简体   繁体   English

有什么方法可以让我知道使用Sublime Text 2的CSS规则会影响哪些文件?

[英]Is there a way I can know what files are affected by a CSS rule using Sublime Text 2?

As above, I want to be able to find all files in a project which are affected by a css rule. 如上所述,我希望能够找到受CSS规则影响的项目中的所有文件。 For example, I type "#header .container li" and I got all the files where that rule is applied. 例如,我键入“ #header .container li”,然后得到应用该规则的所有文件。

Just to be more clear, let's say I have a project with these html files: 为了更清楚一点,假设我有一个包含以下html文件的项目:

File 1:
---------------------
<html>
 <div id="header">
    <div class="container">
      <ul>
         <li>Something</li>
         <li>Something</li>
       </ul>
    </div>
  </div> 
</html>
---------------------

File 2:
---------------------
<html>
 <div id="header2">
    <div class="container">
      <ul>
         <li>Something</li>
         <li>Something</li>
       </ul>
    </div>
  </div> 
</html>
---------------------

File 3:
---------------------
<html>
 <div id="header">
    <div class="container">
      <ul>
         <li class="nomatter">Something</li>
         <li>Something</li>
       </ul>
    </div>
  </div> 
</html>
---------------------

If I type "#header .container li" (CSS rule) I expect to get file 1 and file 3 since them are affected by the css rule I typed. 如果我键入“ #header .container li”(CSS规则),我希望得到文件1和文件3,因为它们受我键入的CSS规则影响。

Use the plugin/package Element Finder (nodejs is required). 使用插件/软件包Element Finder (需要nodejs)。

Copied from an introduction post of its author: 从复制的后引入其作者:

Element Finder is a tool for web developers to find which HTML files contain elements matching a specific CSS selector. 元素查找器是Web开发人员用来查找哪些HTML文件包含与特定CSS选择器匹配的元素的工具。 You might be new on a project, returning to a project that you haven't worked on for a while, or maybe a CSS selector is just unclear and you're not sure exactly which pages it will effect. 您可能是一个项目的新手,回到了一段时间没有从事的项目,或者CSS选择器尚不清楚,您不确定它会影响哪些页面。 Just copy a CSS selector into Element Finder and you will quickly see all of the HTML elements in your project which match that selector. 只需将CSS选择器复制到Element Finder中,您将很快看到项目中与该选择器匹配的所有HTML元素。 For example if you search for div.main , it will show you all the DIV elements with a classname of main . 例如,如果您搜索div.main ,它将为您显示所有类名称为main的DIV元素。

For users on an editor without support for the Element Finder plugin, you can use the same core functionality as a command-line interface with the element-finder npm module (by the same author). 对于不支持Element Finder插件的编辑器上的用户,您可以使用与element-finder npm模块的命令行界面相同的核心功能(由同一作者)。

npm install -g element-finder

elfinder -s ".layout-fluid #sidebar" -i ".tmp, dist" -x "html, php"
  • -s is CSS selector -s是CSS选择器
  • -i is ignored folders -i被忽略的文件夹
  • -x is file extensions to search -x是要搜索的文件扩展名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM