如何避免样式继承

时间:2014-03-06 07:50:09

标签: jquery html css

使用Jquery。每个页面都有table.For表我有一个特定页面的默认样式。每个人都有另一张儿童餐桌。子表我不需要父表样式信息。如何防止子表从父表样式继承属性。请帮助如果您有任何解决方案。提前谢谢。

2 个答案:

答案 0 :(得分:2)

您可以使用直接子选择器来分隔表格:

.someContainer > table{ /* This would match the parent tables */ }
table table { /* This will match tables within a table */ }

答案 1 :(得分:0)

您可以使用not operator

$('table').not('table table').css('background-color','red');

demo


如果你只想用css执行此操作,那么你可以这样做:

table{
   /*parent table style here*/
}
table table{
   /*child table style here*/
}
相关问题