没有在django项目中加载CSS文件
CSS file is not loading in django project
我已经为所有css文件添加了静态文件链接。仍然只有HTML文件显示在浏览器中。CSS文件不起作用。如果有什么不对劲,请告诉我。如何纠正?
我转到index.html页面的页面源代码,然后单击CSS链接。它不显示CSS文件。它显示了一些其他的HTML文件。我得到错误:error page not found
。
index.html
<head>{% load static %}
<link rel="stylesheet" href="{% get_static_prefix as STATIC_PREFIX %} /static/style1.css" type="text/css" />
<title>Login Page</title>
</head>
<body>
<form action="/loginpage/" name="myForm" method="post">
{% csrf_token %}
<fieldset>
<legend>Login</legend>
<br>
<p style="display:inline">Username</p>
<br>
<br>
<input type="text" name="user" autocomplete="off" placeholder="username" size="30" autofocus required/>
<br>
<br>
<p style="display:inline">Password</p>
<br>
<br>
<input type="password" name="pass" autocomplete="off" placeholder="password" size="30" required/>
<br>
<br>
<input type="submit" name="submit" value="Login" style="height:30px; width:70px" />
<br>
<br>
<p style="font-family:arial; color:#FFFFFF;">{{message}}</p>
</fieldset>
</form>
<br>
<br>
<a href="/formlink/" id="sign">Create account</a>
</body>
style1.css
legend {
border: medium none;
left: 39%;
margin: 0 auto;
padding: 0 10px;
position: relative;
text-align: center;
width: auto;
color: #FFFFFF;
font-size: 18px;
font-weight: bold;
font: normal 130% 'century gothic', arial, sans-serif;
}
body {
background-image: url("12.jpg");
}
fieldset {
position: absolute;
left: 600px;
top: 280px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
form {
text-align: center;
}
p {
font: normal 100% 'century gothic', arial, sans-serif;
color: #FFFFFF;
}
#home {
background-color: grey;
color: #ffffff;
display: inline-block;
font-size: 16px;
margin-left: 20px;
opacity: 0.9;
padding: 14px 25px;
position: absolute;
text-decoration: none;
font: normal 100% 'century gothic', arial, sans-serif;
left: 1450px;
top: 100px;
}
#home:hover {
color: black;
text-decoration: underline;
}
#sign {
background-color: grey;
color: #ffffff;
display: inline-block;
font-size: 16px;
margin-left: 20px;
opacity: 0.9;
padding: 14px 25px;
position: absolute;
text-decoration: none;
font: normal 100% 'century gothic', arial, sans-serif;
position: absolute;
left: 680px;
top: 650px;
}
#sign:hover {
color: black;
text-decoration: underline;
}
您已经花了很大的力气来尝试获得静态前缀,然后添加到我认为是静态目录的目录上,无论如何,您只需要使用static
标签
{% get_static_prefix as STATIC_PREFIX %} /static/style1.css
应该是
{% static 'style1.css' %}
相关文章:
- 当我更改Joomla时,它仍然从旧域加载CSS和Javascript
- 在非我的页面上重新加载CSS
- 网站未加载css、js或图像
- 如何在node.js和express中首先加载CSS
- 没有在django项目中加载CSS文件
- 在php中htaccess重定向url后,无法加载css和js
- Javascript可能阻止加载css背景图像
- 无法查找元素'手动加载CSS文件时的CSS属性
- 加载CSS文件并覆盖上一个文件
- 使用 JavaScript 动态加载 CSS 文件
- HTML 不加载 CSS ,刷新后一切正常.同样在移动设备上,它在首次加载时不起作用
- 仅在codeigniter视图页中加载CSS
- 如何在localhost上加载css和引导程序文件
- 为不同的屏幕分辨率加载css样式的Javascript不起作用
- QWebView.setHtml没有't加载CSS文件
- 预加载CSS背景图像[Can't use sprite]
- 如何加载css和js
- 使用requestAnimationFrame异步加载CSS样式表
- 使用 Angular 样式加载 CSS
- IE8 有时不加载 CSS