最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

CSS

运维笔记admin56浏览0评论

CSS

CSS

CSS - 类型的标签选择器?(CSS - Selector of label for type?)

我使用这篇文章解释了如何为给定元素添加标签的选择器。 但是,我想用它来选择给定类型的所有标签(特别是类型收音机)。 试:

label[for=input[type="radio"]] { /* Styles */}

label[for=[type="radio"]] { /* Styles */}

不起作用,我不确定我做错了什么或怎么做对。 有人可以向我解释解决方案吗? 非常感谢!

I'm using this post explaining how to add a selector of a label for a given element. However, I'd like to use it to select all labels for a given type (specifically, the type radio). Trying:

label[for=input[type="radio"]] { /* Styles */}

and

label[for=[type="radio"]] { /* Styles */}

does not work and I'm not sure what I'm doing wrong or how to do it right. Can someone explain the solution to me? Thank you much!

最满意答案

不幸的是,你想要的东西不能用当前的CSS3选择器完成。

这个功能有计划包含在CSS 4级选择器中,但是这个规范还没有最终确定,当然也没有在任何当前的浏览器中实现。

这个想法是一个选择器,看起来像这样:

label /for/ [type="radio"] { /* styles */}

但这是为了未来,而不是现在。 抱歉。

你可以在这里阅读: http : //css4-selectors.com/selector/css4/reference-combination/

同时,如果你需要这种东西,你需要确保构建你的HTML,使元素可以使用当前的CSS选择器相互引用。

例如,如果它们彼此相邻,您可以使用:

label + input[type="radio"] { .... }

这与你现在所得到的一样接近。

Unfortunately, what you're wanting can't be done using current CSS3 selectors.

There are plans for this feature to be included in CSS level 4 selectors, but the spec for this is not yet finalised, and certainly not implemented in any current browsers.

The idea is for a selector that would look something like this:

label /for/ [type="radio"] { /* styles */}

But that's for the future, not for now. Sorry.

You can read about it here: /

In the meanwhile, if you need this kind of thing, you will need to make sure you structure your HTML such that the elements can reference each other using current CSS selectors.

For example, if they're next to each other, you could use this:

label + input[type="radio"] { .... }

That's as close as you'll get for the time being.

label,I'm,type,radio,电脑培训,计算机培训,IT培训"/> <meta name="des

发布评论

评论列表(0)

  1. 暂无评论