我无法链接到HTML中的CSS,但路径是正确的.我已经尝试了一切,甚至魔法也无济于事.
romanchenko_test_task/templates/hello.htmlromanchenko_test_task/static/first-style.csshello.html的:
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/static/first-style.css">
</head>
<body>
<p> Hello world </p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
第一style.css文件:
body {
background: blue;
color: white;
}
Run Code Online (Sandbox Code Playgroud)
您的相关链接不正确.
您的两个文件夹路径是:
romanchenko_test_task/templates/hello.html
romanchenko_test_task/static/first-style.css
Run Code Online (Sandbox Code Playgroud)
因此,要离开您的templates文件夹,您需要使用上升到1级../
尝试:
<link rel="stylesheet" type="text/css" href="../static/first-style.css">
Run Code Online (Sandbox Code Playgroud)