2016-06-19 40 views
-2

我在下面有這個簡單的html/css代碼。 當我嘗試更改我的「歡迎」類中的字體大小時,它實際上不會在div中的任何內容上應用字體大小,背景色,字體重量等。div有ID和類,但類不適用於div

請問我能否解釋爲什麼會發生這種情況。 DIV本身有一個ID和班級。

<html> 
<head> 
    <style> 
    .welcome { 
    font-weight: bold; 
    font-size: 50%; 
    font-style: oblique; 
    background-color: yellow; 
    } 


    a:hover { 
    font-size: 500%; 
    } 

    #greeting { 
    position: absolute; 
    top: 200px; 
    left: 100px; 
    text-align: left; 
    } 

    p { 
    color: green; 
    } 
    </style> 

</head> 


<body> 
<div id="greeting" class=」welcome」> 

Sample Text 
<p>Thank you for coming here!</p> 
<p>Welcome to <a href=」ltu.html」>La Trobe</a></p> 
<p>Thank you for coming here!</p> 
</div> 
</body> 

</html> 
+3

使用了'」'charachter類,使用簡單的'「'或''',它會正常工作,它也是你的錨的href –

+1

相同由於問題是由簡單的印刷錯誤引起的,因此問題投票結束。 –

+0

COPYPASTER CURSE:D – Hrabosch

回答

3

我覺得從某個地方, 你已經使用了引號不正確的人,你可能已經被複制的代碼。

代替

class=」welcome」 

應該

class="welcome" 

(同爲代碼的其他部分)

0

嘗試使用單引號(')而非雙引號(「)。這似乎是問題

1

你用錯誤的字符來定義你的類,而不是你的SE雙或單引號如下,

<div id="greeting" class=」welcome」><!--This is incorrect--> 
<div id="greeting" class="welcome"><!--Use this--> 
<div id="greeting" class='welcome'><!--Or this one--> 
+0

<! - HTML評論 - > – Butterfly

+1

@invissible現在好吧:-) – frnt