当您将鼠标悬停在另一个div标签上时,是否可以更改div标签的属性?
例如,
#tag1 {
/* properties */
}
#tag1 a:hover {
/* new properties */
}
#tag2 {
/* contains a link */
}
Run Code Online (Sandbox Code Playgroud)
其中tag1经历了更改,但tag2包含悬停发生位置的位置(或链接).
可能重复:
CSS:选中 - 更改<td>背景
是否有CSS父选择器?
<ul class="submenu">
<li><a href="...">Submenu 3</a></li>
<li><a href="..." >I need to select this element</a>
<ul class="submenu">
<li><a href="...">Sub-submenu 3</a></li>
<li><a href="...">I need to select this element</a>
<ul class="submenu">
<li><a href="...">Sub-sub-sub 1</a></li>
<li><a href="...">Sub-sub-sub 2</a></li>
Run Code Online (Sandbox Code Playgroud)
基本上,我需要选择<li>位于BEFORE ul元素的每个元素class="submenu"(ul class="submenu"'s parent)
我需要选择这个元素
我想访问锚标记的父元素
<td class="class1">
<div id="id1">
<a class="class2" id="id2" href="link">Link</a>
</div>
</td>
Run Code Online (Sandbox Code Playgroud)
我尝试使用CSS:
.class2:parent:parent {}
但这似乎不起作用.是否有可能在CSS中实现相同的目标?我没有在页面上使用jQuery的灵活性.
有没有办法只定位一个标签有特定类的li元素?
例如:
<li> <a href="#" class="mobile-only">link</a> </li>
<li> <a href="#" class="other-class">link</a> </li>
Run Code Online (Sandbox Code Playgroud)
我可以只定位一个"仅限移动"类的li吗?
我想根据祖先不存在的另一个类来设置一个类的样式。
div:not(.evil-class) .element {
background-color: green;
}Run Code Online (Sandbox Code Playgroud)
<div class="evil-class">
<div class="element">An element within the evil class</div>
</div>
<div class="element">An element NOT in the evil class</div>Run Code Online (Sandbox Code Playgroud)
不确定为什么不起作用?
我知道我可以做相反的事情。对两个元素都应用样式,然后覆盖该样式,但是我不愿意这样做,因为我将覆盖可能在第三方库中更改的样式。
谢谢。
我需要<p>通过检查按钮之一来更改颜色:
<div class="textstyle">
<span class="textarea">
<p class="text">Some text here</p>
</span>
<div class="buttons">
<input type="radio" id="red" name="textbutton" checked/><label for="red">Red</label>
<input type="radio" id="blue" name="textbutton"/><label for="blue">Blue</label>
<input type="radio" id="green" name="textbutton"/><label for="green">Green</label>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
因此,按钮和段落有一个祖父母。如何更改此结构,或应添加哪些CSS规则以使其正常工作?
UPD:无JS或jQuery
我正在设置一些内容拦截器(https://developer.apple.com/documentation/safariservices/creating_a_content_blocker)
我正在测试的 HTML 看起来像这样:
<div class="<random>">
<div>
<div>
<div>
<a class="bad" />
Run Code Online (Sandbox Code Playgroud)
现在,我想知道是否可以有一个 CSS 选择器来选择.bad然后删除整个.randomdiv 块。
我尝试过类似的事情:
{
"action": {
"type": "css-display-none",
"selector": "div > div > div > div >a[href*='speedtest.net']"
},
"trigger": {
"url-filter": "^https?:\/+([^\/:]+\\.)?google.*[:\/]"
}
}
Run Code Online (Sandbox Code Playgroud)
和div:has(a)。
似乎什么都不起作用。
有人知道是否可能吗?我什至找不到任何地方说明苹果对此支持什么(CSS4?)
为什么悬停时.a的背景颜色不会改变?.B?
CSS
.a {
color: red;
}
.b {
color: orange;
}
.b:hover .a {
background-color: blue;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div id="wrap">
<div class="a">AAAA
<div class ="b">BBBB</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
I have two classes with the same exact name and nothing to differentiate them except for "== $0" on the end of the class.
This is the html
<html>
<body>
<div tabindex="0" class="Test" role="button"> == $0
<div tabindex="0" class="Test" role="button">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
I want to select the "== $0" in css.