[英]Why doesn't this work for me? [element] [class] {style}
I am trying to have a normal class for tables, eg 我试图有一个普通的表类,例如
table {style here}
But for some tables I'd like to have a different style 但对于某些桌子,我想使用其他样式
I could just give the table a class and then use that class alone, eg 我可以给表一个类,然后单独使用该类,例如
.specialTable {special style}
But I'd like to try specifying that this is just applicable to tables, eg 但是我想尝试指定这仅适用于表,例如
.specialTable table {special style}
However this isn't working, what's wrong? 但是,这不起作用,怎么了?
.specialTable table
specifies a table
element within an element with the class specialTable
. .specialTable table
在具有specialTable
类的元素.specialTable table
指定一个table
元素。
You want table.specialTable
, which means any table
with the class specialTable
. 你想
table.specialTable
,这意味着任何table
与类specialTable
。
.specialTable table {special style}
The above code will affect any table which has an ancestor (a previous element) with the class specialTable
. 上面的代码将影响具有祖先(前一个元素)且其类为
specialTable
任何表。 That will for instance match the table in 例如,这将匹配表中的
<body class="specialTable">
...
<table>
...
What you want is a table with the class specialTable
in which case the syntax is 您想要的是带有
specialTable
类的表,在这种情况下,语法为
table.specialTable {special style}
It would help if you showed your HTML but I think I see what you're getting at. 如果您显示HTML会有所帮助,但我想我明白您的意思了。
<table class="specialTable">
is not what your CSS specifies. <table class="specialTable">
不是您的CSS指定的内容。 Instead it specifies something like 相反,它指定类似
<div class="specialTable"><table>...</table></div>
Instead in your CSS you can do 相反,您可以在CSS中
table.specialTable { ... }
.specialTable table
Is selecting tables that are descendants of elements with the .specialTable
class. .specialTable table
选择带有.specialTable
类的元素后代的表。
You want table.specialTable
, which selects tables with the class specialTable. 您需要
table.specialTable
,该表选择带有table.specialTable
类的表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.