簡體   English   中英

外部 CSS 樣式表未鏈接

[英]External CSS stylesheet not linking

首先,我想補充一點,在此之前我已經瀏覽了很多帖子,但沒有一個與我的確切情況相符。

問題:

  1. “Lounge.html”是下面顯示的“index”html文件
  2. “test.css”是我試圖鏈接到的外部 .css 文件,也顯示在下面
  3. “Lounge.html”和“test.css”都在同一個文件夾中; 根文件夾
  4. 所有“img”和“a”元素處於工作狀態
  5. 當我在 Microsoft Edge 或 Internet Explorer 中運行“Lounge.html”時,該樣式不會應用於我的頁面。

如果您能幫助我使此外部鏈接正常工作,我將不勝感激。

問候,

機管局

 h1, h2 { font-family: sans-serif; color: gray; } h1 { border-bottom: 1px solid black; } p { font-family: sans-serif; color: maroon; }
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Head First Lounge</title> <link type="text/css" rel="stylesheet" href="test.css" /> </head> <body> <h1>Welcome to the New and Improved Head First Lounge</h1> <p><img src="images/drinks.gif" alt="Drinks" /></p> <p> Join us any evening for refreshing <a href="beverages/elixir.html">elixirs</a>, conversation and maybe a game or two of <em>Dance Dance Revolution</em>. Wireless access is always provided; BYOWS (Bring Your Own Web Server). </p> <h2>Directions</h2> <p> You'll find us right in the center of downtown Webville. If you need help finding us, check out our <a href="about/directions.html">detailed directions</a>. Come join us! </p> </body> </html>

嘗試更新瀏覽器。

對於 IE :如果您仍然收到錯誤,請插入

<meta http-equiv="X-UA-Compatible" content="IE=edge">

在您的<head>部分並嘗試加載它。

希望這會有所幫助!

這可能是瀏覽器緩存的問題。 清除緩存並再次檢查。 清除緩存的簡單方法是在添加后添加一些隨機字符串? 到網址。 示例

http://example.com/test.html?somerandomtext

為了解決這個問題,如果您想稱呼它為“修復”,我只需將兩個文件(html、css)上傳到網絡托管服務器。 'index' html 文件立即受到外部樣式表的影響,這與我嘗試使用本地方法不同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM