是否可以将HTML属性应用于CSS中的Div标签?(Is it possible to apply a HTML attribute to a Div Tag in CSS?)

编程入门 行业动态 更新时间:2024-10-20 11:52:17
是否可以将HTML属性应用于CSS中的Div标签?(Is it possible to apply a HTML attribute to a Div Tag in CSS?)

嗨,我有一个应用了Css角色的通用DIV。

我想知道CSS是否允许在DIV中设置HTML标记的样式(仅适用于具有该角色的DIV),该标记具有Css角色。

请让我知道你的想法。 谢谢你的时间。

<div class="Role"> <table></table> </div> .Role { // Style for <table> tag. }

Hi I have a generic DIV with a Css Role applied.

I would like to know if CSS allows to set the style for an HTML Tag inside a DIV (only for DIV with that Role) which has a Css Role.

Please let me know your thoughts. Thanks for your time on this.

<div class="Role"> <table></table> </div> .Role { // Style for <table> tag. }

最满意答案

你有几个选择:

例如, 后代选择选择器.Role table选择用于应用包含在元素中的所有表,无论如何,使用类Role。

子选择器 .Role > table将关联的规则应用于具有类Role的元素的子(而不是后代)的表

例如,考虑这个html片段:

<div class="Role"> <table id="t1"> <tr><td> <table id="t2"> .... </table> </td></tr> </table> </div> .Role表将css规则应用于表#t1 表#t2 .Role> table将css规则应用于表#t1 .Role> table table将规则应用于表#t2 跳转到表#t1

You have several options to go:

The descendant selector selector .Role table, for example, select for apply all the table that are contained into an element, whatever, with class Role.

The child selector .Role > table will apply the associated rules to the tables that are child (not descendant) of the element with class Role

For example, consider this html fragment:

<div class="Role"> <table id="t1"> <tr><td> <table id="t2"> .... </table> </td></tr> </table> </div> .Role table will apply the css rule to table#t1 and table#t2 .Role > table will apply the css rule to table#t1 only .Role > table table will apply the rule to table#t2 skipping to table#t1

更多推荐

本文发布于:2023-08-01 15:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1361517.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用于   属性   标签   CSS   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!