【问题标题】:CSS not working at all in all browsersCSS 在所有浏览器中都不起作用
【发布时间】:2025-12-02 08:00:01
【问题描述】:

我正在构建一个简单的网站,并发现虽然 CSS 在 Chrome 中运行良好(我通常使用它),但在 Firefox 或 IE 中根本不行。就像它是一个带有图片和文本的空白页面,就像我没有编写任何 CSS 一样。 HTML 加载良好,但很明显 CSS 根本没有被使用。

这是我所有的 HTML:

<!DOCTYPE HTML>

<html>

<head>
<title>Apple Tree House</title>
<link rel="stylesheet" type="css" href="stylesheet.css" />
<link rel="shortcut icon" href="root/icon.ico" type="image/ico" />

</head>
<body>

<div id="container">

<header>
<img src="root/logo.png" id="logo" width="300px" height="300px">
<h2>New Bed and Breakfast</h2>
<h1>Opening January 2015</h1>
<h4>Apple Tree House, Farndon Road, Woodford Halse, Northamptonshire</h4>
</header>

<div id="textcontainer">
---Basic text info here---
</div>

<footer>
<img src="root/footer.png" id="footbanner">
</footer>
</div>

</body>

</html>

还有我的 CSS:

html, body{
margin: 0; 
padding: 0;

}

body {
background-color:#85A366;
font-family:Arial, Helvetica, Sans-serif;
font-size:12pt;
margin:0 auto;
padding-left:10px;
padding-right:10px;

}


#container{
width:80%;
height:100%;
padding-left:5px;
padding-right:5px;
padding-bottom:0px;
padding-top:0px;
text-align:center;
color:black;
background:#FFFFEE;
margin:0 auto;
font-family: Goudy Old Style,Garamond,Big Caslon,Times New Roman,serif;
font-weight:600;
font-style:italic;
font-size:13pt; 
color:#7D5833;

}

h1, h2, h3, h4, h5, h6 {
color:#472400;
}
h1 { font-size: 40px; }
h2 { font-size: 32px; }
h4 { font-size: 24px; }

#textcontainer{

width:45%;
text-align:center;
margin:0 auto;
top:auto;
}

footer{ 
text-align:center;
height:100px;
 }
#footbanner { 
max-width:100%;
max-height:100%; 
}

@media screen and (max-width:420px) {
table{
 font-size:8pt;
 }
 #container {
    width:100%;
    }
 }

您可以在其中看到任何使它在 Chrome 中工作但在其他浏览器中完全不能工作的东西?

【问题讨论】:

  • 什么版本的 IE 和 FireFox?
  • 尝试使用 type="text/css"
  • 安迪/夏尔玛,就是这样!现在完美运行。谢谢你。 :)

标签: html css google-chrome internet-explorer firefox


【解决方案1】:

&lt;link/&gt;type 应该是text/css 而不仅仅是css,如下所示:

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

【讨论】:

    【解决方案2】:

    我不是这里的专家,但我注意到您使用“css”而不是“text/css”。 也许这样可以解决问题?

    虽然奇怪的是这对我有用: http://prntscr.com/58m1fi

    【讨论】: