我想选择倒数第二个。这是哪个产品,请推荐我。
<ul>
<li><a href="#">Home</a></li><li><a href="#">About</a></li>
<li><a href="#">Setting</a></li>
<li><a href="#">Product</a></li>
<li><a href="#">COntact US</a></li>
</ul>
<style>
ul li a{
color: black;
}
ul li a:nth-child(n-1) {
color:red;
}
</style>
Run Code Online (Sandbox Code Playgroud) 给定以下 HTML 标记,我只想仅在存在2个相同元素时(而不是存在 1 个时)应用 (S)CSS 。
我不想使用 JavaScript 来计算元素数量并应用另一个类,但是,我觉得这是唯一的方法。
div {
a + a {
// I want to apply styles to both a tags, not just the second one
// WHEN 2 a tags exists
}
}
Run Code Online (Sandbox Code Playgroud)
div {
a + a {
// I want to apply styles to both a tags, not just the second one
// WHEN 2 a tags exists
}
}
Run Code Online (Sandbox Code Playgroud) 当我的组件中可能存在内部元素时,为什么 svelte 会声明未使用的 CSS 选择器?
<div class="users">
{#each [1,2,3,4,5] as id}
<User name={id} />
{/each}
</div>
<style>
.users > * {
margin-right: 5px;
}
</style>
Run Code Online (Sandbox Code Playgroud)
错误:
Unused CSS selector ".users > *" (12:4)
回复: https://svelte.dev/repl/6c8b4a6a808c4aee80e51af58b4fcda4 ?version=3.44.0
用户是一个普通的div。不确定我是否应该使用另一种模式来实现这一目标。
我有一些关于 css 选择器的问题。请帮忙。在下面的代码中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
selector {
color: blue;
}
</style>
</head>
<body>
<section>
<p id="apple">apple
<div class="orange">orange</div>
</p>
<p class="mango"> mango
<div>banana</div>
</p>
</section>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如果选择器是部分,则所有部分的子项都会继承颜色属性。为什么当选择器是p时不是这样呢?
选择器=节p,目标节内的所有p元素。为什么当selector = p div 时不起作用?
Selector = section #apple,按预期定位 id="apple" 的 p 元素。
但 Selector = section #apple .orange 不起作用。先感谢您!
我被困在子元素位置。子元素的属性有多项,父元素的属性也有多项。我发现很难找到子元素。元素操作 click() 不起作用。
网页:
<div class="locale-selector" xpath="1">
<span class="locale-selector-heading"> Your location and language</span>
<div class="locale-selector-country-wrapper" data-metrics-section="Site_lvl1_LocLangSelector">
<a href="#" class="locale-selector-country" aria-controls="localization-container" aria-haspopup="true" aria-expanded="false">
<div class="locale-selector-flag-heading-wrapper">
<span class="flag-header-global flag-hong-kong"></span>
<span class="locale-selector-country-heading">Hong Kong</span>
</div>
<span class="locale-selector-chevron-arrow"></span>
</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
span标签有多个类,div标签有多个相同的类。
如何在类上执行 click() 操作?
class="locale-selector-country-heading"
Run Code Online (Sandbox Code Playgroud)
我的尝试:
cy.get('.locale-selector-country-heading').contains('Hong Kong').click()
Run Code Online (Sandbox Code Playgroud)
错误:
<span class="locale-selector-country-heading">Hong Kong</span>
该元素<span.locale-selector-country-heading>不可见,因为其父元素<div.locale-selector-flag-heading-wrapper>具有 CSS 属性:visibility: hidden
为了有一个整体的背景图像一整页,我应该设置背景图像html,body或两者兼而有之?
对于jquery中的单选按钮,我会为此做同样的事吗?
$("select option:not(:selected)").removeClass("takethis");
Run Code Online (Sandbox Code Playgroud) 我一遍又一遍地阅读文档,我无法理解为什么这不起作用:
从函数内部调用以下内容:
alert($(this).parent().parent().html());
Run Code Online (Sandbox Code Playgroud)
返回看起来像这样的东西:
<div class="something1">
<div class="whereThisStarted">stuff</div>
</div>
<div class="something2">stuff</div>
<div class="somethingSpecial">stuff</div>
<div class="something4">stuff</div>
Run Code Online (Sandbox Code Playgroud)
我想得到"特别的东西".在我看来,以下任何一个都应该工作,但它们都返回null.
alert($(this).parent().parent().children(".somethingSpecial").html());
alert($(this).parent().parent().filter("div.somethingSpecial").html());
Run Code Online (Sandbox Code Playgroud)
这有什么问题?
谢谢
我目前正在我的投资组合网站上工作,它使用非常简单的导航.然而,我想要做的是当类型被悬停时,类型下方的阴影变得更强(读取:更高的不透明度/更暗).
现在我的代码看起来如下,并没有产生任何错误,但也没有做任何事情.
/* Work | Play | About | Contact */
/* Shadow Opacity */
$(document).ready(function() {
$('#workShadow', '#playShadow', '#aboutShadow', '#contactShadow').fadeTo( 0, 0.1);
});
/* Shadow Hover effect */
$(document).ready(function() {
$('a#work').hover(function() {
$('#workShadow').fadeTo( 200, 0.5);
}, function() {
$('#workShadow').fadeTo( 400, 0.1);
});
});
/* Type movement on hovering */
$(document).ready(function() {
$('a.shift').hover(function() { //mouse in
$(this).animate({ paddingTop: 85, paddingBottom: 2 }, 200);
}, function() { //mouse out
$(this).stop().animate({ paddingTop: 75, paddingBottom: 12 }, 400); …Run Code Online (Sandbox Code Playgroud) 在以下代码中,如何选择具有以图像结尾的所有<tr>元素?我很茫然...<td>cancelled.png
<table>
<tr> <----- select this whole tr
<td>
<img src="/images/icons/invoice-cancelled.png" alt="cancelled" />
<a href='/orders/invoice.aspx?invoiceid=63'>X1087</a>
</td>
... other tds, some with "-cancelled.png" others with something different
</tr>
....
</table>
Run Code Online (Sandbox Code Playgroud) css-selectors ×10
css ×5
jquery ×4
html ×2
cypress ×1
get ×1
javascript ×1
location ×1
parent-child ×1
radio-button ×1
svelte ×1