簡體   English   中英

我的 CSS 沒有在 Internet Explorer 11 和 Firefox 中加載! 僅適用於 Chrome

[英]My CSS is not loading in Internet Explorer 11 and Firefox! Only works with Chrome

我正在創建一個簡單的網頁。 我的 CSS 僅適用於 Chrome。 它不適用於 Firefox 和 IE11。

這是我的 HTML

<html>
<head>
    <title>text</title>
    <link href="css/stylesheet.css" type="css/stylesheet" rel="stylesheet" media="all"/>
</head> 
    <body>
        <h1><b><u>Adding a new Visitor</u></b></h1><br/></br>
        <div class="wrapper">
            <figure>
                <img src="images/advis1.png"/>
                <figcaption style="padding-top: 12px;">text</figcaption>
            </figure>
            <hr/>
            <figure>
                <img src="images/advis2.png"/>
                <figcaption style="padding-top: 12px;">text</figcaption>
            </figure>
            <hr/>
            <figure>
                <img src="images/advis3.png"/>
                <figcaption style="padding-top: 12px;">text.</figcaption>
            </figure>
            <hr/>
            <h3><u>Result</u></h3> 
                <img src="images/advis4.png"/>
                <br/>
                <img src="images/advis5.png"/>
            </div>
            <footer>
                Author: Malcolm Tanti | Contact information: <a href="mailto:xxx">xxxxm</a>
            </footer>
    </body>

這是我的 CSS

h1 {

    text-align: center;
    border-bottom: double;
    border-left: double;
    border-right: double;
    width: 75%;
    margin: 0 auto;
    padding-top: 25px;
    padding-bottom: 25px;
    background-color: #C4CEDD;
    box-shadow: inset 0 20px 20px -20px #000000;
}

body {
    padding:0px;
    margin:0px;
    border:none;
    background-color: #7ea2d6;
    font-family: "Arial Rounded MT Bold", "Helvetica Rounded", Arial, sans-serif;
}

.wrapper {
    box-shadow: inset 0 20px 20px -20px #000000;
    border: double;
    padding-top: 50px;
    padding-bottom:50px;
    width: 75%;
    margin: 0 auto;
    text-align: center;
    font-size: 20px;
    background-color: #C4CEDD;
}

img { 
   border:3px double;
   display: block;
   margin: 0 auto;
}

footer {
    padding-top: 10px;
    text-align: center;
    font-size: 14px;
}

我對 CSS 但和 HTML 很陌生。 它在 Chrome 中運行良好,這讓我想知道問題是什么。 我的問題是沒有任何 css 加載,並且所有圖像和文本都沒有對齊。 我什至沒有任何顏色

我測試了您的代碼,發現如果您從以下位置刪除 type="css/stylesheet" :

<link href="css/stylesheet.css" type="css/stylesheet" rel="stylesheet" media="all"/>

所以它看起來像:

<link href="css/stylesheet.css" rel="stylesheet" media="all">

您也不需要在結尾處關閉 / 。

它解決了這個問題。 (在標准模式下測試而不是怪癖)

你不應該需要這樣做:

<h1><b><u>Adding a new Visitor</u></b></h1><br/></br>

下划線、字體粗細和間距(邊距/填充)應該在你的 CSS 中完成:

<h1>Adding a new Visitor</h1>

h1 {
    text-align: center;
    border-bottom: double;
    border-left: double;
    border-right: double;
    width: 75%;
    margin: 0 auto;
    padding-top: 25px;
    padding-bottom: 25px;
    background-color: #C4CEDD;
    box-shadow: inset 0 20px 20px -20px #000000;

    text-decoration: underline;
    font-weight: bold;
}

希望有幫助。

通過在導入樣式type="css/stylesheet"時使用type="text/css"而不是type="css/stylesheet"

對於 Internet Explorer 添加此

 <!--[if lt IE 9] < script src = "//html5shiv.googlecode.com/svn/trunk/html5.js" > < /script> <![endif]-->

這可能是因為瀏覽器緩存。 請按CTRL + F5清除瀏覽器緩存

我遇到了同樣的問題,以上都沒有解決我的問題。 就我而言,最終的解決方案很簡單:

不知何故,如果您在本地運行頁面(如在瀏覽器中獨立運行),IE 不會加載 CSS。 我將完全相同的腳本上傳到網絡服務器,它的工作原理非常棒!

msvk_23 是對的。 我有一個本地 html 頁面,而不是 post-it。 在我安裝 Notepad++ 之后,它在 Internet Explorer 和 Edge 中都搞砸了,但在 Google Chrome 中卻沒有。 檢查注冊表時,它說: text/xml 按照建議將其更改為 text/css 后,它立即在 Internet Explorer 和 Edge 中工作。

謝謝 msvk_23 :)

regedit 的圖片在此處輸入圖片說明

試試這個選項:

請運行 regedit.exe 並導航到 HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes.css 鍵

修改:“內容類型”從“text/plain”改為“text/css”

對我來說,在 IE 11 中根本無法識別 css。通過在 regedit 中更改此條目。 它在我的電腦上完美運行。

暫無
暫無

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

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