如何保存Chrome开发者工具样式面板的CSS更改?

发布于 2024-11-26 22:58:51 字数 850 浏览 1 评论 0原文

如何保存 样式面板 的 CSS 更改href="http://code.google.com/chrome/devtools/docs/overview.html" rel="noreferrer">Google Chrome 开发者工具?

在该工具的网站上提到我们可以在资源面板中看到所有更改< /a>

在此处输入图像描述

但我正在本地处理 CSS 文件,但资源面板中未显示更改我

在此处输入图像描述

输入图像此处描述

顺便问一下,您知道 Chrome 开发者工具有哪些插件、工具可以保存 css 更改吗? 我知道 Firebug 有很多 https://stackoverflow.com/search?q=firebug+CSS+changes +保存

How to save CSS changes of Styles panel of Google Chrome Developer Tools?

At tool's website it's mentioned that we can see all change in resource panel

enter image description here

But I'm working locally on a CSS file but changes are not showing in Resource panel for me

enter image description here

enter image description here

By the way Do you know any add-ons , tools to save css changes of Chrome Developer tools?
I know for Firebug there are many https://stackoverflow.com/search?q=firebug+CSS+changes+save

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

娇纵 2024-12-03 22:58:51

您可以从 Chrome 开发工具本身保存 CSS 更改。 Chrome 现在允许您将本地文件夹添加到工作区。允许 Chrome 访问该文件夹并将该文件夹添加到本地工作区后,您可以将 Web 资源映射到本地资源。

  • 导航至开发人员工具的“源”面板,在左侧面板(列出文件的位置)中右键单击,然后选择将文件夹添加到工作区通过单击“元素”面板中所选元素的每个 CSS 规则右上角的样式表,您可以快速访问“源”面板中的样式表。

在此处输入图像描述

  • 添加文件夹后,您必须授予 Chrome 访问该文件夹的权限。
    允许 chrome 访问

  • 接下来需要将网络资源映射到本地资源。

在此处输入图像描述

  • 重新加载页面后,Chrome 现在会加载映射文件的本地资源。为了让事情变得更简单,Chrome 只向您显示本地资源(这样您就不会混淆您正在编辑本地资源还是网络资源)。要保存更改,请在编辑文件时按 CTRL + S

ps

您可能需要打开映射文件并开始编辑才能让 Chrome 应用本地版本(日期 201604.12)。

You can save your CSS changes from Chrome Dev Tools itself. Chrome now allows you to add local folders to your Workspace. After allowing Chrome access to the folder and adding the folder to the local workspace, you can map a web resource to a local resource.

  • Navigate to the Sources panel of the Developer Tools, Right-click in the left panel (where the files are listed) and select Add Folder to Workspace. You can get to a stylesheet in the Sources panel quickly by clicking the stylesheet at the top-right of each CSS rule for a selected element in the Elements panel.

enter image description here

  • After adding the folder, you'll have to give Chrome access to the folder.
    Allow chrome access

  • Next, you need to map the network resource to the local resource.

enter image description here

  • After reloading the page, Chrome now loads the local resources for the mapped files. To make things simpler, Chrome only shows you the local resources (so you don't get confused on as to whether you are editing the local or the network resource). To save your changes, press CTRL + S when editing the file.

p.s.

You may have to open the mapped file(s) and start editing to get Chrome apply the local version (date 201604.12).

逆光下的微笑 2024-12-03 22:58:51

DevTools 技术作家和开发人员在这里倡导。

从 Chrome 65 开始,本地覆盖是一种全新的轻量级方法这。这是与工作区不同的功能。

设置覆盖

  1. 转到面板。
  2. 转到覆盖选项卡。
  3. 单击选择要覆盖的文件夹
  4. 选择要将更改保存到的目录。
  5. 在视口顶部,单击允许以授予 DevTools 对该目录的读写访问权限。
  6. 做出你的改变。在下面的 GIF 中,您可以看到 background:rosybrown 更改在页面加载期间持续存在。

覆盖演示

覆盖的工作原理

当您在 DevTools 中进行更改时,DevTools 会将更改保存到计算机上文件的修改副本中。当您重新加载页面时,DevTools 会提供修改后的文件,而不是网络资源。

覆盖和工作区之间的区别

工作区旨在让您使用 DevTools 作为 IDE。它使用源映射将您的存储库代码映射到网络代码。真正的好处是,如果您正在缩小代码,或者使用需要转译的代码(例如 SCSS),那么您在 DevTools 中所做的更改(通常)会映射回原始源代码。另一方面,覆盖允许您修改和保存网络上的任何文件。如果您只想快速尝试更改并在页面加载时保存这些更改,那么这是一个很好的解决方案。

DevTools tech writer and developer advocate here.

Starting in Chrome 65, Local Overrides is a new, lightweight way to do this. This is a different feature than Workspaces.

Set up Overrides

  1. Go to Sources panel.
  2. Go to Overrides tab.
  3. Click Select Folder For Overrides.
  4. Select which directory you want to save your changes to.
  5. At the top of your viewport, click Allow to give DevTools read and write access to the directory.
  6. Make your changes. In the GIF below, you can see that the background:rosybrown change persists across page loads.

overrides demo

How overrides work

When you make a change in DevTools, DevTools saves the change to a modified copy of the file on your computer. When you reload the page, DevTools serves the modified file, rather than the network resource.

The difference between overrides and workspaces

Workspaces is designed to let you use DevTools as your IDE. It maps your repository code to the network code, using source maps. The real benefit is if you're minifying your code, or using code that needs to get transpiled, like SCSS, then the changes you make in DevTools (usually) get mapped back into your original source code. Overrides, on the other hand, let you modify and save any file on the web. It's a good solution if you just want to quickly experiment with changes, and save those changes across page loads.

淑女气质 2024-12-03 22:58:51

新版本的 Chrome 有一个称为工作区的功能可以解决这个问题。您可以定义网络服务器上的哪些路径对应于系统上的哪些路径,然后只需使用 ctrl-s 进行编辑和保存。

请参阅:http://www.html5rocks.com/en/tutorials/developertools/revolutions2013/

New versions of Chrome have a feature called workspaces which addresses this issue. You can define which paths on your webserver correspond to which paths on your system, then edit and save with just ctrl-s.

See: http://www.html5rocks.com/en/tutorials/developertools/revolutions2013/

像你 2024-12-03 22:58:51

我知道这是一篇旧帖子,但我以这种方式保存它:

  1. 转到“源”窗格。
  2. 单击“显示导航器”(在左侧显示导航器窗格)。在此处输入图像描述
  3. 单击所需的 CSS 文件。 (它将在编辑器中打开,其中包含您所做的所有更改)
  4. 右键单击编辑器并保存您的更改。

您还可以查看本地修改来查看您的修订,非常有趣的功能。
还可以使用脚本。

I know it is an old post, but I save it this way :

  1. Go to Sources pane.
  2. Click Show Navigator (to show the navigator pane on left).enter image description here
  3. Click the CSS file you want. (It will open in the editor, with all changes you made)
  4. Right click on editor and Save your changes.

You can also see Local Modifications to see your revisions, very interesting feature.
Also work with scripts.

凉栀 2024-12-03 22:58:51

您正在查找“资源”的错误部分。

它不在“本地存储”下,而是在“框架”下:

上面的屏幕截图显示了原始样式与开发工具中进行的新修改。您可以右键单击左侧窗格中的项目并将其保存回磁盘。

You're looking in the wrong section of "Resources".

It's not under "Local Storage", it's under "Frames":

The above screenshot shows a diff of the original styles against the new modifications made in the devtools. You can right-click the item in the left pane and save it back to disk.

路弥 2024-12-03 22:58:51

Tincr Chrome 扩展更容易安装(无需运行节点服务器),并且还附带类似 LiveReload 的开箱即用功能!谈论双向编辑! :)

Tin.cr 网站

Chrome 网上应用店链接

安迪的博客文章

Tincr Chrome extension is easier to install (no need to run node server) AND also comes with LiveReload like functionality out the box! Talk about bi-directional editing! :)

Tin.cr Website

Chrome Web Store Link

Andy's Blog Article

蓝礼 2024-12-03 22:58:51

既然 Chrome 18 已于上周发布并提供了所需的 API,我在Chrome 网上应用店。该扩展会自动将开发者工具中 CSS 或 JS 的更改保存到本地磁盘。去看看吧。

Now that Chrome 18 was released last week with the required APIs, I published my chrome extension in the Chrome web store. The extension automatically saves changes in CSS or JS in Developer tools into the local disk. Go check it out.

小清晰的声音 2024-12-03 22:58:51

2019 年更新:由于其他答案有点过时,我将在此处添加更新的答案。在最新版本中,无需将 chrome 文件夹映射到文件系统。

输入图像描述这里

所以,假设我在桌面上有一个包含 HTML、CSS、JS 文件的 Web 文件夹,当我在 chrome 中进行更改时,我想更新该文件夹:=

1)您需要一个正在运行的本地服务器,例如 Node等等,或者这个 vscode 扩展创建适合您的服务器:实时服务器 VSCode 扩展,安装它,运行服务器。

2)从运行的本地服务器加载chrome中的html页面。

3)打开devTools->Sources->Filesystem->Add文件夹到工作区

在此处输入图像描述

4) 添加运行本地服务器时使用的文件夹。最新的 chrome 中不需要额外的映射!哒哒!

详细信息使用工作区编辑文件

请注意,对样式选项卡不会反映在文件系统文件上。
输入图像描述这里
相反,您需要转到 devtools->source->your_folder,然后在那里进行更改并重新加载页面以查看效果。

UPDATE 2019: As other answers are bit outdated, I'll add updated one here. In latest version there's no need to map the chrome folder to filesystem.

enter image description here

So, suppose I have a web folder containing HTML,CSS,JS files in desktop which i want to be updated when I make changes in chrome:=

1) You'd need a running local server like node etc, alternatively this vscode extension creates the server for you: live server VSCode extension, install it, run the server.

2) load the html page in chrome from running local server.

3) Open devTools->Sources->Filesystem->Add folder to workspace

enter image description here

4) Add the folder which is used in running local server. No additional mapping is required in latest chrome! Ta-da!

More on it Edit Files With Workspaces

Note that the changes made on the styles tab will NOT reflect on the filesystem files.
enter image description here
Instead you need to go to devtools->source->your_folder and then make your changes there and reload the page to see the effect.

來不及說愛妳 2024-12-03 22:58:51

只要您没有将 CSS 粘贴到 element.style 中:

  1. 转到您已添加的样式。应该有一个链接说检查器样式表:

在此处输入图像描述

  1. 单击它,它将打开您在源面板中添加的所有 CSS

  2. 复制并粘贴它 - 耶!

如果您已经使用element.style

您只需右键单击 HTML 元素,单击“编辑为 HTML”,然后复制并粘贴包含内联样式的 HTML。

As long as you haven't been sticking the CSS in element.style:

  1. Go to a style you have added. There should be a link saying inspector-stylesheet:

enter image description here

  1. Click on that, and it will open up all the CSS that you have added in the sources panel

  2. Copy and paste it - yay!

If you have been using element.style:

You can just right-click on your HTML element, click Edit as HTML and then copy and paste the HTML with the inline styles.

找回味觉 2024-12-03 22:58:51

仅供参考,如果您使用内联样式或直接修改 DOM(例如添加元素),工作区无法解决此问题。这是因为 DOM 存在于内存中,并且没有与 DOM 的活动状态关联的实际文件。

为此,我喜欢从控制台拍摄 dom 的“之前”和“之后”快照:
copy(document.getElementsByTagName('html')[0].outerHTML)

然后我将其放入 diff 工具中以查看我的更改。

比较工具图片

全文:https://medium.com /@theroccob/get-code-out-of-chrome-devtools-and-into-your-editor-defaf5651b4a

FYI, If you're using inline styles or modifying the DOM directly (for instance adding an element), workspaces don't solve this problem. That's because the DOM is living in memory and there's not an actual file associated with the active state of the DOM.

For that, I like to take a "before" and "after" snapshot of the dom from the console:
copy(document.getElementsByTagName('html')[0].outerHTML)

Then I place it in a diff tool to see my changes.

Diff tool image

Full article: https://medium.com/@theroccob/get-code-out-of-chrome-devtools-and-into-your-editor-defaf5651b4a

ㄟ。诗瑗 2024-12-03 22:58:51

要回答有关可以保存更改的任何扩展程序的问题的最后部分,有修补程序

它允许您将 Chrome 开发工具中的更改直接保存到 GitHub。从那里,您可以在 GitHub 上设置接收后挂钩以自动更新您的网站。

To answer the last part of your question about any extensions that can save changes, there is hotfix

It allows you to save changes from Chrome Dev Tools directly to GitHub. From there you can set up a post-receive hook on GitHub to automatically update your website.

挽容 2024-12-03 22:58:51

重要!
不要忘记在 CSS 文件顶部指定 sourceURL,如下所示:

/*# sourceURL=/home/folder/file.css */

这在动态加载脚本时尤其重要!如果使用选项 Source > 正确设置,这是 Chrome DevTools 允许文件覆盖的唯一方法。覆盖。

我制作了一个 NPM 包来帮助任何需要将 sourceURL 添加到项目中所有文件的人!
https://www.npmjs.com/package/add-sourceurl

Important!
Don't forget to specify the sourceURL at the top of your CSS file like this:

/*# sourceURL=/home/folder/file.css */

This is especially important when scripts are loaded dynamically! It's the only way for Chrome DevTools to allow file overrides if set up correctly with the option Source > Overrides.

I made an NPM package to help anyone who needs to add sourceURL to all files in a project!
https://www.npmjs.com/package/add-sourceurl

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文