简体   繁体   English

CSS样式表不起作用?

[英]CSS Style Sheet is Not Working?

I have the following code in my stylesheet... 我的样式表中有以下代码...

body 
{        
    background-image:url('Background.png');
}

td.Header
{
    background: purple Url("Header.png");
    height:100px;
    width:100%;
    border:5px;
    border-style:solid;
    border-color:blue;
}

Now This is how I use it in my html: 现在,这就是我在html中使用它的方式:

<table align="center" width="800px">
    <tr>
        <td class="header" height="100px">Where's my background and border?</td>
    </tr>
    <tr>
        <td>The Normal Stuff </td>
    </tr>
</table>

I do have my stylesheet linked to my html file. 我的样式表确实链接到了html文件。 The only thing that works on my css sheet is my body class. 在我的CSS工作表上唯一起作用的是我的身体类。 My background image is appearing for my body. 我的身体出现了背景图像。 But for my td.header nothing at all is working. 但是对于我的td.header来说,什么都没有用。 Please help. 请帮忙。

Thanks Alot 非常感谢

CSS can be case sensitive. CSS可能区分大小写。 If you are using the XHTML doctype, then CSS class names are case sensitive, so a class name of header is not the same as Header . 如果您使用的是XHTML文档类型,然后CSS类名大小写敏感的,所以一个类名header是不一样的Header

Check if you're using a doctype of XHTML. 检查您是否使用XHTML文档类型。 If so, you'll need to change your class attribute in the html to exactly match the class selector in the stylesheet. 如果是这样,则需要在html中更改您的class属性,使其与样式表中的类选择器完全匹配。

If your DOCTYPE is HTML though, case sensitivity doesn't matter, and something else is going on. 如果您的DOCTYPE是HTML,则区分大小写无关紧要,并且还有其他事情发生。

Note that HTML5, like XHTML, will also be case sensitive. 请注意,HTML5和XHTML一样,也区分大小写。

CSS class names are case-sensitive. CSS类名称区分大小写。 If you change "td.Header" to "td.header", does it work? 如果将“ td.Header”更改为“ td.header”,是否有效?

Hope this helps! 希望这可以帮助!

your first problem is your css rule 您的第一个问题是CSS规则

td.Header

css is case sensitive so it should be the same case as your HTML: css区分大小写,因此应该与HTML大小写相同:

td.header

second, in CSS you dont need to use quotes for urls. 其次,在CSS中,URL不需要使用引号。 In fact i read somewhere that its better not to (cant recall where or i'd cite it :) 实际上,我读过一个最好不要读的地方(想不起来在哪里还是我会引用它:)

在CSS中td.header ,因为类名和ID区分大小写

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM