两个链接的CSS文件不工作 [英] Two Linked CSS Files Not working

查看:73
本文介绍了两个链接的CSS文件不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<head>

    <title>Water Bureau</title>
    <link rel="shortcut icon" href="/favicon.ico" />
    <link rel="stylesheet" href="/css/main.css" type="text/css" media="screen" title="Main CSS">
    <link rel="stylesheet" href="custom.css" type="text/css" media="screen" title="Custom Styles">
    <script language="JavaScript" src="/shared/js/createWin.js" type="text/javascript"></script> 

</head>

这是代码,但custom.css不工作。它不工作。如果我们添加一个@import到main.css OR到头,而不是一个它工作正常。有任何想法吗?我们也删除了媒体=屏幕,以及。

Thats the code, but the "custom.css" isn't working. It doesn't work at all. If we add a @import into main.css OR into the header instead of a it works fine though. Any ideas? We also got rid of the media="screens" on both as well.

它的CSS内部工作正常,它只是当我们堆叠这两个,第一一个解析是浏览器读取的唯一一个。所以如果我们互换主要下面的习俗,定制比作品,但NONE主要工作。和自定义只是有CSS的代码片段,并不覆盖所有的CSS在main,只有1个元素。

The CSS inside of it is working fine, it's just when we stack those two, the first one parsed is the only one read by the browser. So if we swap main below custom, custom than works but NONE of main works. and custom just has snippet of CSS, and doesn't override all the CSS in main, just 1 element.

我不能想出来!我们有其他的样式表在头部(我们试图修复这个),他们工作很好...

I can't figure it out! We have other ed stylesheets in the head (which we took out for trying to fix this) and they worked fine...

推荐答案

像hsource说的,尝试验证这两个css文件。

Like hsource said, try validating both css files.

http://jigsaw.w3.org/css-validator/

也可以试试这个,没有这两个css文件的标题相同的文件夹,相对于正在导入它们的页面:

Also just try this, without that title thing with both css files in same folder, both relative to the page which is importing them:

<link rel="stylesheet" type="text/css" href="css/main.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/custom.css" media="screen" />

也可能是因为你没有使用任何doctype, ,有关的东西可能是你的问题。所以尝试这样:

It also might be that because you are not using any doctype and also you are not closing your link tags, something related to that might be your problem. So try this:

<!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" dir="ltr" lang="en-US">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/main.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/custom.css" media="screen" />
</head>

这篇关于两个链接的CSS文件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆