[英]css sibling selectors. Target sibling element from element with a specific tag
I am currently trying to target a specific element on my mobile site. 我目前正在尝试在移动网站上定位特定元素。 The software package we are using locks down the HTML code, so I am unable to add any classes or ID tags.
我们使用的软件包会锁定HTML代码,因此我无法添加任何类或ID标签。 However, I feel that it is possible to target the speicific element I am after.
但是,我觉得有可能针对我所追求的特定要素。
My problem is I am attempting to target the <nav>
element on a page, based on the value given to an adjacent UL with a specific title tag. 我的问题是,我试图根据给定具有特定标题标签的相邻UL的值,将页面上的
<nav>
元素定位为目标。 Here is the current code: 这是当前代码:
<html>
<body>
<nav id="navigationWrapper"></nav>
<ul id="home" title="Home"></ul>
</body>
</html>
In this particular instance, the title="Home"
portion of the code changes based on which page the user is currently viewing. 在此特定实例中,代码的
title="Home"
部分根据用户当前正在查看的页面而更改。 The title tag of the current page is applied. 当前页面的标题标签将被应用。
My hope is to be able to somehow target the <nav>
element on just the home page, based on the dynamic value given to the "title=" portion of the sibiling ul element. 我希望能够根据赋予ul元素的“ title =“部分的动态值,以某种方式仅将主页上的
<nav>
元素作为目标。 Is this possible? 这可能吗?
I've tried what I thought would work #navigationWrapper + ul[title="Home"]
, but it does not. 我已经尝试了我认为可以
#navigationWrapper + ul[title="Home"]
,但没有成功。
不可以。(除了:last…
伪类),不能根据文档中后面的元素来选择元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.