【问题标题】:CSS :target another elementCSS:定位另一个元素
【发布时间】:2014-03-19 19:37:36
【问题描述】:

是否也可以像示例中那样定位另一个元素?

<a href="#AAA">click</a>
<div id="AAA">some content</div>
<div id="BBB">some content</div>

类似...

#AAA:target #BBB{color:red}

【问题讨论】:

  • 你只是在找我想你他可能想要#AAA:target,#BBB:target{color:red}吗? target also 是什么意思?

标签: css css-selectors target


【解决方案1】:

在这种情况下,您可以使用adjacent sibling combinator, +

EXAMPLE HERE

#AAA:target + #BBB {
    color:red
}

根据标记,使用general sibling combinator, ~ 可能会更好。 (example)

【讨论】:

  • 与 ~ 完美搭配。谢谢!
猜你喜欢
  • 2012-06-24
  • 1970-01-01
  • 1970-01-01
  • 2013-03-17
  • 1970-01-01
  • 1970-01-01
  • 2013-10-11
  • 2013-03-25
  • 1970-01-01
相关资源
最近更新 更多