2012-08-05 51 views
0
<html> 
    <head> 
    <style type="text/css"> 
    #sidebar p { 
     font-family: Verdana; 
     font-size: .9em; } 

     #sidebar .intro { 
      font-family: Georgia; 
      font-size: 1.25em; 
      color:red; 
      } 

    </style> 

    </head> 
    <body> 
    <div id=」sidebar」> 
     <p class=」intro」> 
      As you can see, the more CSS styles you create, the greater the potential for formatting 
      snafus. For example, you may create a class style specifying a particular 
     font and font size, but when you apply the style to a paragraph, nothing happens! 
      This kind of problem is usually related to the cascade. Even though you may think 
     that directly applying a class to a tag should apply the class’s formatting properties, 
      it may not if there’s a style with greater specificity. 

     You have a couple of options for dealing with this kind of problem. First, you can 
     use !important (as described in the box above) to make sure a property always 
     applies. The !important approach is a bit heavy handed, though, since it’s hard to 
     predict that you’ll never, ever, want to overrule an !important property someday. 
     Read on for two other cascade-tweaking solutions. 
    </p>  
</div> 

    </body> 
</html> 

#sidebar p風格具有特異性的101(100用於ID,和1爲標記 選擇器),而.intro風格具有10特異性(等級選擇器10分)。由於101大於10,因此#側欄p優先。更改.intro到#sidebar .intro改變其以110改變特異性

特殊性,即使我有這個改變我的結果是不來

任何人都可以解釋我。

輸出:應爲紅色,字體大小,1.25em和FONT-FAMILY -Georgia

回答

1

圍繞ID sidebar和類名intro的報價無效。 」sidebar」應該是"sidebar"

瀏覽器將ID解釋爲」sidebar」而不是sidebar,因此,您的規則都不匹配。

+0

只是愚蠢的錯誤。我花時間去認識它。它的工作現在。我理解的概念,但我在編碼方面犯了錯誤。謝謝 – swati16 2012-08-05 16:44:02

+0

我是新來的。所以我不知道如何回答問題和其他問題。感謝一次引導我agai引導但我在哪裏可以找到完整的指導方針? – swati16 2012-08-05 16:52:24

+0

@ swati16:在** [FAQ]。** – 2012-08-05 16:53:43