简体   繁体   English

Chrome 开发者工具 - 如何锁定 css 类列表?

[英]Chrome Developer Tools - How to lock css classlist?

I need to inspect a search bar.我需要检查一个搜索栏。 The search bar is initially hidden and only shows after clicking on the search icon.搜索栏最初是隐藏的,只有在单击搜索图标后才会显示。

However, if I click on my developer tools then the search bar dissapears again... If the search box should appear, then a class named active is added.但是,如果我单击我的开发人员工具,则搜索栏会再次消失...如果应该出现搜索框,则会添加一个名为active的类。 So I tried to add the class manually but if I inspect other elements, then the active class is removed again...因此,我尝试手动添加该类,但如果我检查其他元素,则会再次删除活动类...

Is there a way to lock the classlist?有没有办法锁定类列表? I could write a javascript interval method which sets the classlist, as a workaround.我可以编写一个 javascript 间隔方法来设置类列表,作为一种解决方法。

eg例如

setInterval(function() {
    jQuery("#debug")[0].classList = "label icon faSearch active";
}, 1000 );

But is there an easier way?但是有没有更简单的方法呢?

If you only need to debug your CSS, you can press F8 in the Sources tab of Developer console and you'll pause every Javascript code execution.如果您只需要调试 CSS,您可以在开发者控制台的 Sources 选项卡中按 F8,您将暂停每个 Javascript 代码执行。 That will prevent any Javascript code from altering the CSS classes.这将防止任何 Javascript 代码更改 CSS 类。

Then you can change any CSS class manually.然后您可以手动更改任何 CSS 类。

Hope this helps,希望这可以帮助,

When we inspect a page by chrome developer tools, By selecting the particular element, the styles of the element will be shown, where in we will have option to freeze the element's state by clicking ":hov" as shown in the screenshot below,当我们通过 chrome 开发者工具检查页面时,通过选择特定元素,将显示元素的样式,其中我们可以选择通过单击“:hov”来冻结元素的状态,如下面的屏幕截图所示,

在此处输入图片说明

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

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