CSS 和嵌套表
我有一个 html 表,其中包含多个其他表。我的问题是内部表继承与外部表相同的规则。
有没有办法超越外面的规则?我基本上想告诉内表:
嘿内表你的名字是“X”。我希望你忘记所有关于你的外表和它的规则。我希望您遵守这些其他具体规则。
有没有办法在 HTML/CSS 中实现这一点?例子?
I have html table that contains multiple other tables. My problem is that the inner tables inherit the same rules as the outer table.
Is there a way to over ride the rules of the outer table? I basically want to tell the inner table:
Hey inner table Your name is "X". I want you to forget all about your outer table and its rules. I want you to follow these other specific rules.
IS there a way to make that happen in HTML/CSS? Examples?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设您有以下
HTML
CSS - 没有类/ID
有时您可以逃脱:
CSS - 带类/ID
有关类和 ID 的小注释。类可以应用于您想要的任意数量的元素并带有指定的样式。 ID 只能用于一个元素,因为这是该元素的标识。这意味着如果您有两个嵌套表,则需要为第二个表提供新的唯一 ID。
ID 在 CSS 中显示为#。因此,如果您只想将其用于特定 ID,则将是:
在 CSS 中使用类(如示例所示),是一个句点。如果您使用句点而不指定元素,它将用于具有相同名称的类的所有元素,因此最好指定您希望将其附加到哪个元素。
I'll assume you have the following
HTML
CSS - Without class/ID
Sometimes you can get away with:
CSS - With Class/ID
A little note with Classes and IDs. Classes are something that can be applied to as many elements as you desire and carry the styling specified. IDs should only be used for one element, as this is an identification to that element. That means if you have two nested tables, you need to give that second table a new unique ID.
ID's are shown as # in CSS. So if you just want to use it for the specific ID, it will be:
Using the class (as the example shows) in CSS, is a period. If you use the period without specifying the element, it will be used for all elements that have a class of the same name, so it's best to specify what element you want it attached to.
最简单的方法是 class 和 id。请务必使用该元素。
您还可以使用
或组合两者
希望这会有所帮助。
The easiest way is class and id. Be sure to use the element.
You can also use
or combine the two
Hope this helps.
这将确保只有选定表的直接子级(而不是嵌套表)才会收到样式。
This will ensure that only direct children of the selected table, and not of nested tables, will receive the styles.