2

如何在下面给出的代码中使用 myabilities 类访问第一个元素?

<div class="span6">
      <h3 class="srvc-title">Responsive Design</h3>             
      <p class="srvc-detail">Crafting great experiences to suit the capabilities of every browser.</p>
      <p class="myabilities">The number of web-accessible devices is truly a wonder of our information age. It’s also a daunting canvas for design.</p>
      <p class="myabilities">Mobile phones, tablets, desktops — it’s hard to even categorise these days. I specialise in embracing the Web’s ubiquity. It’s my job to design for all experiences.</p>
      <p class="myabilities">Great design can’t be achieved in isolation. In fact, it’s two development practices that are the secret; feature detection and progressive enhancement. That means a multi-tiered design to match the capabilities of any browser.</p>
      <p class="myabilities">Complicated for us but for users — it just works.</p>
</div>  
4

1 回答 1

1

不幸的是,伪类喜欢:nth-child并且:nth-of-type只会根据它们的type来查找元素,而不是你可能期望的它们的 class 或 ID 值。但是鉴于您的加价(假设它不会改变),您也可以使用:

div.span6 .srvc-detail + p {
    color: gold;
}

http://jsfiddle.net/E3GSV/3/

于 2013-08-18T13:17:38.647 回答