2017-09-14 122 views
1

我在w3schools &筆編輯器中的在線編輯器中嘗試了以下代碼。這是代碼。HTML「樣式」標記不起作用

body { 
 
background-color: lavenderblush 
 
} 
 
.red-text { 
 
    color: red; 
 
} 
 
h1 { 
 
    font-family: Tangerine, times new roman; 
 
    font-size: 55px; 
 
} 
 
p { 
 
    font-size : 18px; 
 
    font-family: inconsolata; 
 
}  
 
.thick-salmon-border { 
 
    border-color: salmon; 
 
    border-width: 5px; 
 
    border-style: solid; 
 
    border-radius: 50%; 
 
} 
 
.smaller-image { 
 
    width: 120px; 
 
    height: 120px; 
 
} 
 

 
.thick-royalblue-border { 
 
    border-color: royalblue; 
 
    border-width: 5px; 
 
    border-style: solid; 
 
    border-radius: 50%; 
 
} 
 
.thick-green-border { 
 
    border-color: green; 
 
    border-width: 5px; 
 
    border-style: solid; 
 
    border-radius: 50%; 
 
} 
 

 
.thick-sandybrown-border { 
 
    border-color: sandybrown; 
 
    border-width: 5px; 
 
    border-style: solid; 
 
    border-radius: 50%; 
 
} 
 
.thick-lightpink-border { 
 
    border-color: lightpink; 
 
    border-width: 5px; 
 
    border-style: solid; 
 
    border-radius: 50%; 
 
} 
 
.thick-rosybrown-border { 
 
    border-color: rosybrown; 
 
    border-width: 5px; 
 
    border-style: solid; 
 
    border-radius: 50%; 
 
} 
 
.box { 
 
    border-style: solid; 
 
    border-color: rosybrown; 
 
    border-width: 5px; 
 
} 
 
.AntiqueWhite-box { 
 
    background-color: AntiqueWhite; 
 
    padding: 20px; 
 
    margin: 20px; 
 
} 
 
.MistyRose-box { 
 
    background-color: MistyRose; 
 
    padding: 20px; 
 
    margin: 20px; 
 
}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine"> 
 
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rancho&effect=shadow-multiple"> 
 
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inconsolata"> 
 
<h1 class="red-text font-effect-shadow-multiple">My Favorite Songs</h1> 
 
<p> 
 
    <a href="https://en.wikipedia.org/wiki/Ed_Sheeran"><img class="smaller-image thick-salmon-border" src="http://cdn3.thr.com/sites/default/files/2015/07/ed_sheeran.jpg" alt="My Favorite Songs"></a> 
 
    <a href="https://en.wikipedia.org/wiki/Shape_of_You"><img class="smaller-image thick-royalblue-border" src="https://images.genius.com/fc44439c55552eb23d4a9ecb28a21f06.1000x1000x1.jpg " alt="My Favorite Songs"></a> 
 
    <a href="https://en.wikipedia.org/wiki/Thinking_Out_Loud"><img class="smaller-image thick-green-border" src="https://upload.wikimedia.org/wikipedia/en/a/ad/X_cover.png" alt="My Favorite Songs"></a> 
 
</p> 
 
<div class=" box AntiqueWhite-box"> 
 
    <p>Ed Sheeran</p> 
 
    <ul> 
 
     <li><a href="https://www.musixmatch.com/lyrics/Ed-Sheeran/Shape-of-You">Shape of You</a></li> 
 
     <li><a href="https://www.musixmatch.com/lyrics/Ed-Sheeran/Thinking-Out-Loud">Thinking Out Loud</a></li> 
 
     <li><a href="https://www.musixmatch.com/lyrics/Ed-Sheeran/Galway-Girl">Galway Girl</a></li> 
 
    </ul> 
 
    <form action="/submit-Ed Sheeran" id="Ed Sheeran-form"> 
 
     <label> 
 
      <input type="radio" name="reaction" checked>Like</label> 
 
     <label> 
 
      <input type="radio" name="reaction">Dislike</label> 
 
     <label> 
 
      <input type="radio" name="reaction">None of Above</label> 
 
     <br> 
 
     <label> 
 
      <input type="checkbox" name="electronic devices" checked>Phone</label> 
 
     <label> 
 
      <input type="checkbox" name="electronic devices">Laptop</label> 
 
     <label> 
 
      <input type="checkbox" name="electronic devices">Mp3</label> 
 
     <br> 
 
     <input type="text" placeholder="Ed Sheeran URL"> 
 
     <button type="submit">Submit</button> 
 
    </form> 
 
</div> 
 
<p> 
 
    <a href="https://en.wikipedia.org/wiki/Adele"><img class="smaller-image thick-sandybrown-border" src="http://www.hellomagazine.com/imagenes//celebrities/2017080741334/adele-grenfell-tower-victims-screening/0-214-739/adele-t.jpg" alt="My Favorite Songs"></a> 
 
    <a href="https://en.wikipedia.org/wiki/Rolling_in_the_Deep"><img class="smaller-image thick-lightpink-border" src="http://netstorage.metrolyrics.com/albums/2777347adele-21.jpg" alt="My Favorite Songs"></a> 
 
    <a href="https://en.wikipedia.org/wiki/Hello_(Adele_song)"><img class="smaller-image thick-rosybrown-border" src="https://i.pinimg.com/736x/a9/95/9c/a9959c17c8260650136fdc4a7d8bb218--adele-in-concert-adele--album.jpg" alt="My Favorite Songs"></a> 
 
    <p> 
 
     <div class="box MistyRose-box"> 
 
      <p>Adele</p> 
 
      <ul> 
 
       <li><a href="https://www.musixmatch.com/lyrics/Adele-3/Rolling-in-the-Deep">Rolling In the Deep</a></li> 
 
       <li><a href="https://www.musixmatch.com/lyrics/Adele-3/Someone-Like-You">Someone Like You</a></li> 
 
       <li><a href="https://www.musixmatch.com/lyrics/Adele-3/Hello">Hello</a></li> 
 
      </ul> 
 
      <form action="/submit-Adele" id="Adele"> 
 
       <label> 
 
        <input type="radio" name="reaction" checked>Like</label> 
 
       <label> 
 
        <input type="radio" name="reaction">Dislike</label> 
 
       <label> 
 
        <input type="radio" name="reaction">None of Above</label> 
 
       <br> 
 
       <label> 
 
        <input type="checkbox" name="electronic devices" checked>Phone</label> 
 
       <label> 
 
        <input type="checkbox" name="electronic devices">Laptop</label> 
 
       <label> 
 
        <input type="checkbox" name="electronic devices">Mp3</label> 
 
       <br> 
 
       <input type="text" placeholder="Adele URL"> 
 
       <button type="submit">Submit</button> 
 
      </form> 
 
     </div>

BTW,我在Windows的 「邊緣」 瀏覽器跑這個。怎麼了? 此代碼工作正常,直到昨天,但現在CSS不起作用。 w3schools或codepen有什麼變化嗎?有沒有類型?請幫忙。

+1

它在jsfiddle中正常工作https://jsfiddle.net/fxmea0m8/ –

+0

我看到你的簡短答案被刪除了!對不起,但是,你能否稍後解釋一下「隱形」角色的位置,以便這個問題可以在將來幫助某人?然後,您可以接受您的答案,將問題標記爲「已關閉」。 –

回答

-2

你錯就錯在你的身體標記background-color屬性分號

body{ 
    background-color: lavenderblush; 
    } 
2

首先:使用最新的Taq(必填):

<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <title></title> 
    <link rel="stylesheet" href=""> 
    <style type="text/css" media="screen"> 

    </style> 
</head> 

:使用樣式類似的代碼這個(不要求):

<style type="text/css" media="screen"> 

</style> 

:將;在你的CSS代碼(在第6行的末尾)(不需要)結束:

body { 
    background-color: lavenderblush; 
    } 

我希望第二你第三幫助。

:)

0

它在我的codepen側正常工作。

你應該嘗試硬刷新(Ctrl + F5)

OR

清除緩存和Cookie然後加載頁面

OR

嘗試鐵桿版本如在URL中添加?1?之後的任何內容,然後點擊URL。 例如

http://<your URL>.html?1 

最好的做法是使用樣式和腳本在<head >標籤,因爲它會在頁面之前加載,你會看到設計在其最好的。如果它沒有得到解決,那麼上面的解決方案將工作,如果它是緩存相關的問題。

使用Style<head>

+0

我認爲他有頭taq但不寫在這裏! – 2017-09-14 06:22:05