[已解决]CSS不生效问题
css不生效的原因:html标签没写完整,漏了“<”、”>”或者“/”等;这是版面设计失效的最常见原因之一。当我们了解到这是多少精致的版块设计失效的罪魁祸首时,总会大吃一惊。样式被层叠;比如!importantCSS语法错误;拼写错误之类的balabala选择器写错;常见错误 id选择器:#xxx,class选择器:.xxx没有写rel属性。就这个问题,找了一晚上起因是遇到了浏览器报错
css不生效的原因:
-
html标签没写完整,漏了“<”、”>”或者“/”等;
这是版面设计失效的最常见原因之一。 -
样式被层叠;
比如!important
-
CSS语法错误;
拼写错误之类的balabala -
选择器写错;
常见错误id选择器:#xxx
,class选择器:.xxx
-
没有写rel属性。
就这个问题,找了一晚上起因是遇到了浏览器报错 ->because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checkin
,某博客说删掉rel属性,我照做了,但是CSS样式表直接不生效了!找了1小时问题所在遇到该问题
because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checkin
不要慌,先清除一下浏览器缓存,不是rel属性的问题,rel属性删除后浏览器不传入该CSS,于是造成了CSS的不生效。 -
node.js中http模块不生效。
来源是node.js的某个练习
const fs = require('fs')
const path = require('path')
const http = require('http')
const server = http.createServer()
server.on('request', (req, res)=>{
let url = req.url
fs.readFile(path.join(__dirname, url), 'utf8', (err, dataStr)=>{
if(err) return res.end('<h1>404 not find!</h1>')
// CSS样式不生效的话将下面这个代码注释掉
// res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.end(dataStr)
})
})
server.listen(802, ()=>{
console.log('802 start')
})
5の详细对比:
有rel属性,浏览器传入了这个CSS样式表
没rel属性,浏览器不传入这个CSS样式表
主要是记录一下
更多推荐
所有评论(0)