为什么我的CSS无法生效?

时间:2022-02-26 16:46:01

I have a problem I see every so often - I create a CSS file, link it in a webpage, but then it sometimes takes effect and sometimes doesn't. I've set up a very simple example which has the problem.

我有一个问题,我经常看到 - 我创建一个CSS文件,将其链接到网页,但它有时生效,有时不生效。我已经建立了一个非常简单的例子,它有问题。

This page is at http://localhost:8080/myapp/index.faces (It's generated from JSF, but I don't think that's relevant - I've copied the HTML source here)

这个页面位于http:// localhost:8080 / myapp / index.faces(它是从JSF生成的,但我不认为这是相关的 - 我在这里复制了HTML源代码)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>My Page</title>
    <link href="styles.css" rel="stylesheet" type="text/css"/>
  </head>
  <body>
    blah blah...
  </body>
</html>

I can view the styles.css file no problem from the browser address bar, at http://localhost:8080/myapp/styles.css

我可以在浏览器地址栏中查看styles.css文件没问题,http:// localhost:8080 / myapp / styles.css

It was working, then after redeploying the app it stopped. Really annoying. I'm using IE7 - can anyone offer any enlightenment on this behaviour?

它正在运行,然后在重新部署应用程序后停止了。真烦人我正在使用IE7 - 任何人都可以对这种行为提供任何启示吗?

1 个解决方案

#1


0  

As soon as I ask the question, I work out what's going on!

我一问这个问题,就知道发生了什么事!

In this case - something odd has happened, rolling back my JSP file to a previous version - losing the styling attributes. So everything was working fine, but the CSS classes weren't there in the HTML.

在这种情况下 - 发生了奇怪的事情,将我的JSP文件回滚到以前的版本 - 丢失了样式属性。所以一切都运行正常,但HTML中没有CSS类。

Thanks for the help, anyway!

无论如何,谢谢你的帮助!

#1


0  

As soon as I ask the question, I work out what's going on!

我一问这个问题,就知道发生了什么事!

In this case - something odd has happened, rolling back my JSP file to a previous version - losing the styling attributes. So everything was working fine, but the CSS classes weren't there in the HTML.

在这种情况下 - 发生了奇怪的事情,将我的JSP文件回滚到以前的版本 - 丢失了样式属性。所以一切都运行正常,但HTML中没有CSS类。

Thanks for the help, anyway!

无论如何,谢谢你的帮助!