无法理解css中的元素 [英] Unable to understand element in css
本文介绍了无法理解css中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<style>
table.skinned tr th.name {
width: 400px;
}
</style>
in the above code i am not able to understand the use of .name. in the remaining code these is no keyword is used with name. can you please suggest what is the purpose of .name
推荐答案
的目的是什么?这真的非常简单,你可能会遇到一些麻烦以后。
这个规则基本上是说:
a)用class ='skinned'
b)在那个/那些表中,将样式应用于具有class ='name'的元素
基本上 -
■如果没有点(。)或散列(#),则定位元素类型(例如:a,p,td,div等)
■如果有一个点(。),则定位一个具有点后面的类的元素。 (例如:.active,.someClass,.hilighted)
■如果有一个哈希(#),你的目标是一个id跟随哈希的元素(例如: #myOutput,#idOfSingleElement,#redBtn等等)
哪里有类似
的地方table.skinned
,你正在寻找一个皮肤类的表元素
当你有table tr th
,你正在寻找一个包含在表元素中的tr元素中的元素 - 这可以合理地简化为th
在你的情况下,css也有点冗长 - 你可以针对完全相同的元素(不多也不少)具有以下内容:
< table> table.skinned th.name - 理由是您只需要具有特定类的th
元素, _so if as_它们存在于table
元素中,类skinned 。由于 th
元素必须存在于tr
元素中,并且您不希望特定的tr
元素,你不需要指定< cod> tr - 暗示或假设。
It's really very simple, and likely something you'll have no trouble searching for later on.
What that rule basically says is:
a) target a table/tables with the class='skinned'
b) inside that/those tables, apply the style to the th element that has the class='name'
Basically -
■ If there's no dot (.) or hash (#) you target an element type (E.g: a, p, td, div etc)
■ If there's a dot (.) you target an element with the class that follows the dot. (E.g: .active, .someClass, .hilighted)
■ If there's a hash (#) you target an element with the id that follows the hash (E.g: #myOutput, #idOfSingleElement, #resetBtn, etc, etc)
Where you have something like
table.skinned
, you're looking for a table element with the class of skinned
When you havetable tr th
, you're looking for a th element that is contained in a tr element that's contained in a table element - This could reasonably be simplified toth
In your case, the css is also a little verbose - you could target the exact same elements (no more and no less) with the following:
<table>table.skinned th.name - the rationale being that you only wantth
elements with a specific class, _so long as_ they exist in atable
element with the class ofskinned
. Sinceth
elements have to exist in atr
element, and you don't want specifictr
elements, you don't need to specify the <cod>tr - it's implied or assumed.
你在html代码中找到了以下内容吗?
Did you find the following in your html code?
<th class="name">
如果找不到,那就好了,那么你可以从css中删除th.name。
参考: css_selectors [ ^ ]
这篇关于无法理解css中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文