English 中文(简体)
CSS 副手——Match属价值,从中开始
原标题:CSS Attribute selector - Match attribute values that begin with

我试图通过界定<代码>,确定包含一个菜单的所有<代码>。 ID 类似:

<ul id="menutop">
    <li><a href="#">item1</a></li>
    <li><a href="#">item2</a></li>
    <li><a href="#">item3</a></li>
</ul>
<ul id="menumain">
    <li><a href="#">item1</a></li>
    <li><a href="#">item2</a></li>
    <li><a href="#">item3</a></li>
</ul>

根据我的理解,我可以使用:

ul[id|= menu ]>li>a {color:#f00;}

(<a> direct child of a <li> direct child of an <ul> that has its id starting with menu) But it doesn t work.

寻找一个比喻使我看到了这一[问题]? 这表明,ID是一种属性,而不是一种财产,因此,我不了解它为什么没有工作。 我做了什么错误?

这里与CSS2匹配特性和根据W3标准赋予价值的联系(

最佳回答

根据W3文件:

[att|=val]
Represents an element with the att attribute, its value either being exactly "val" or beginning with "val" immediately followed by "-" (U+002D)

http://www.w3.org/TR/CSS2/selector.html#attribute-selectors

这意味着ul>[>ul>[>;>。

这可能是为什么不工作的原因,因为脑膜炎和脑膜炎不匹配。

您可以尝试将身份证重新命名为男性和男性主,或者可以:

<ul id="menutop" class="menu">
    <li><a href="#">item1</a></li>
    <li><a href="#">item2</a></li>
    <li><a href="#">item3</a></li>
</ul>
<ul id="menumain" class="menu">
    <li><a href="#">item1</a></li>
    <li><a href="#">item2</a></li>
    <li><a href="#">item3</a></li>
</ul>

和贵方:

ul.menu li a {color: #f00;}

这将使你能够按需要在所有菜单上打上彩色,同时仍然能够拥有独特的身份证,供使用,并按需要使用。

而且,正如Pekka提到的那样,> 遴选人没有得到广泛支持,因此,您现在可能希望重新审议其使用情况。

问题回答

为了确保最大程度的兼容性,我将给每一年级的<代码>menu和使用。

ul.menu>li>a {color:#f00;}

请注意:<代码>> 遴选人未获得国际电子数据处理公司的支持;8。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Private FireFox plugin

I m looking at getting a FireFox plugin developed - but is it possible to create a plugin that is for private use only, so only those I share it with have it and not open to the masses? Need this for ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Cross-browser development

I m developing a web application for a new service, starting from Firefox 3.5. The interface design is tableless, only using divs + CSS & performance-blessed practices. Now, while being ...

Cross browser way of setting IFrame to "about:blank"?

Does anybody know a proper, cross-browser way to "empty" an IFrame? Is "about:blank" recognized without error across all browsers? Is it valid to give an IFrame an empty src?

热门标签