我正在开发一个网页,需要选择另一个元素的“父级”,但是不起作用,即使在这样简单的页面上也不起作用:
<!DOCTYPE html>
<html lang="es" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div class="">
<a href="#" class="prueba">prueba!</a>
</div>
<style media="screen">
div:has(.prueba) {
border: solid 2px red;
}
</style>
</body>
</html>
如果我在样式部分使用div,它是有效的,但我需要捕获第一个子元素中的div,即"class prueba"的"a",但对我来说无效。
谢谢!
div:has( > .prueba)
。 - Temani Afif