如何将 .css 文件添加到我的 node.js(非 express)代码中?我正在做一个简单的初学者代码。我尝试了以下但它不起作用:
function start(response) {
console.log("Request Handler start was called");
var body = '<html>' +
'<head>' +
'<link href="style.css" rel="stylesheet" type="text/css">' +
'</head>' +
'<body >' +
'<center><h1>Hello World</h1></center>' +
'<marquee>Welcome!!!</marquee>'+
'<br>'+
'<form action="/upload" method="post">' +
'<textarea name="text" rows="8" cols="40" ></textarea>' +
'<input type="submit" value="submit text" />' +
'</form>' +
'</body>' +
'</html>';
response.writeHead(200,{'Content-Type': 'text/html'});
response.write(body);
response.end();
}
我的 style.css 就是这样:
body { margin-left : 10% ; margin-right : 10% ; margin-top: 10% ; margin-bottom : 10%; background : #D8BFD8; }
h1 { font-weight: bold;color : #8A084B;text-align: center;}
marquee { color:#305d7b; }
p {background: #acbeca; width: 700px; color: black;font-style: italic;}