English 中文(简体)
是否使用杂货类总是更妥善的想法,以摆脱压倒一切的问题?
原标题:Is using css class always a better idea to get rid of style overriding problems?
  • 时间:2010-04-25 07:34:58
  •  标签:
  • css

取代<代码>#id 消除最突出的问题和进口问题始终是一个更好的想法?

#content ul li a {font-size:10px}

#content .demo ul li a {font-size:15px}
问题回答

<代码>id为识别符号,理想的是,它只应用于某一项内容,而<代码>}<>>>>则仅用于某一项内容。 可多次用于多个要素。

SEE: Id vs 级

某类人胜诉时总是胜诉,鉴于同一要素有两个相互冲突的规则,浏览器将根据规则的特殊性计算每项规则的分数。 规则的每一部分都裁定了要点,然后适用了最要点的规则。

  • html selectors (div, p, etc) are +1
  • class selectors (.class) are +10
  • id selectors (#id) are +100

例如:

#content ul li a {font-size:10px} = 100 + 1 + 1 + 1 = 103
#content .demo ul li a {font-size:15px} = 100 + 10 + 1 + 1 + 1 = 113

帮助的希望

无,我认为,只应当使用 Java本海事组织处理的独特内容。

如果计算了特别安全局规则的重要性,则其具体程度高于类别,但这不能成为使用规则的理由。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签