简体   繁体   English

CSS文件中只有一部分无效

[英]Only a part of css file doesn't work

I'm new to js and I was following a tutorial to learn about node.js. 我是JS的新手,我正在按照一个教程学习Node.js。 I used middleware and tried to adapt my css file into pages. 我使用了中间件,并尝试将css文件改编成页面。 But only a part of css file doesn't work even though I just copied and moved the whole style part from html file to css file. 但是,即使我只是将整个样式部分从html文件复制并移动到了css文件中,但css文件中的只有一部分不起作用。

Here is my style.css . 这是我的style.css

<style type="">
body {
    background: skyblue;
    font-family: verdana;
    color: #fff;
    padding: 30px;
}
h1 {
    font-size: 48px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}
h2 {
    font-size: 30px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}
p, li {
    font-size: 16px;
    text-align: center;
}

And only background: skyblue this part doesn't work. 只有background: skyblue这部分无效。

The part I handle with static files is just like this. 我处理静态文件的部分就是这样。 app.use('/assets', express.static('assets'))

All other styles does work and I have no idea what is the cause. 所有其他样式都可以使用,我不知道是什么原因。

Remove <style type=""> from your CSS. 从CSS中删除<style type=""> That's HTML, not CSS. 那是HTML,而不是CSS。

The skyblue color is equal to #87CEEB - might try and change to a HEX color instead as it seems node.js has trouble interpreting the skyblue color. 天蓝色等于#87CEEB可能会尝试将其更改为十六进制颜色,因为node.js似乎无法解释skyblue蓝色。 You can see the color references here CSS Colors 您可以在此处查看颜色参考CSS颜色

It is not possible that only a part of CSS is not working. 不可能只有一部分CSS无法正常工作。

Inspect body tag and check from where it is picking background style. 检查body标签,并从中选择背景样式。 Include your CSS right after the the CSS file from which background style is currently picked. 在当前从中选择背景样式的CSS文件之后添加CSS。 My most probable guess is it is picking background style from some other file. 我最可能的猜测是它正在从其他文件中选择背景样式。

Make sure there is no in-file and inline CSS giving background style. 确保没有提供背景样式的文件内嵌和内联CSS。

or use 或使用

background: skyblue !important; 背景:天蓝色!重要;

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

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