如何在 Chrome 开发工具中设置元素的:悬停状态并编辑孩子的样式

2023-11-29前端开发问题
33

本文介绍了如何在 Chrome 开发工具中设置元素的:悬停状态并编辑孩子的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

假设我们有这种风格:

.parent .child { ... }

.parent:hover .child { ... }

两个选择器都为子元素设置样式.

Both selectors set style for child elements.

我想要编辑第二种样式.

What I would like is to edit the second style.

  1. 我点击 .parent 并在 Chrome 开发者工具中设置 :hover 状态
  2. 单击 .child 元素以获取孩子的样式,但是...
  1. I click on .parent and set :hover state in Chrome developer tools
  2. Click on a .child element to get to child's style but...

当我点击 .child 时,父级上的悬停消失了(因为它现在设置在 .child 上).

When I click on .child the hover on parent is gone (because it's now set on .child).

虽然这在 Firebug 中有效,但我在 Chrome 中需要它...

铬 21.0.1180.89 米

Chrome 21.0.1180.89 m

推荐答案

更新:Chrome现在有以下新热点:

Update: Chrome now has the following new hotness:

  1. 右键单击子元素并选择检查元素
    • Chrome 将打开元素视图并选择项目
       

在元素视图中,右键单击父元素并选择强制元素状态 :hover"

In the Elements view, right-click the parent element and choose "Force Element State :hover"

再次在 Elements 视图中选择子元素.

Select the child element in the Elements view again.

<小时>

以下是旧的、有效但令人讨厌的技术:

用这个JSFiddle测试:

  1. 悬停子元素本身(也悬停在父元素上).
  2. 右键单击孩子.
  3. 使用键盘(不是鼠标)将上下文菜单选择向下移动到检查元素"并按 Enter
    • Hurrah,悬停的父级和选定的子级的 CSS 规则可用
  1. Hover the child element itself (which also hovers the parent).
  2. Right-click the child.
  3. Using the keyboard (not mouse) move the context menu selection down to "Inspect Element" and press Enter
    • Hurrah, the CSS rule for the hovered parent and selected child is available

请注意,如果您在第 3 步中做错了(如果您使用鼠标),则必须先选择不同的元素,然后再重试.

Note that if you do it wrong in step 3 (if you use the mouse) you have to select a different element first before trying again.

这篇关于如何在 Chrome 开发工具中设置元素的:悬停状态并编辑孩子的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

layui 单选框、复选框、下拉菜单不显示问题如何解决?
1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
2024-11-09 前端开发问题
313

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

缩放背景图像以适合 ie8 窗口
Scale background image to fit ie8 window(缩放背景图像以适合 ie8 窗口)...
2024-04-19 前端开发问题
11

IE7 (IETEster) 中的@fontface 无法正常工作
@fontface in IE7 (IETEster) not working properly(IE7 (IETEster) 中的@fontface 无法正常工作)...
2024-04-19 前端开发问题
9

Safari 5.1 打破 CSS 表格单元格间距
Safari 5.1 breaks CSS table cell spacing(Safari 5.1 打破 CSS 表格单元格间距)...
2024-04-19 前端开发问题
3

Coffeescript 中的源映射 - 错误未映射到源
Source Mapping in Coffeescript - errors not mapped to source(Coffeescript 中的源映射 - 错误未映射到源)...
2024-04-19 前端开发问题
5