2017-09-03 110 views
0

我剛剛在一個靜態文件夾中添加了一些CSS,我的django項目只適用於某些元素。該文件在網站上加載,但是當我嘗試對段落元素進行更改時,什麼都不會發生。當我在外部樣式表中編輯body元素時,它會對樣式產生影響。這裏是我的CSS和HTML:Django CSS只適用於某些元素

HTML

<!DOCTYPE html> 
<html> 
{% load staticfiles %} 
<head> 
    <title>Would-be Username</title> 
    <link rel="stylesheet" type="text/css" href="{% static 'css/test.css'%}"> 
</head> 
<body> 
    <img src="{{ current_user.userprofile.profile_picture.url }}"> 
    <p>Username: Would-be Username</p> 
    <p>Name: {{ current_user.userprofile.first_name }} {{ current_user.userprofile.last_name }}</p> 
    <p>Email: {{ current_user.username }}</p> 
    <a href="{{ request.path }}edit/">Edit</a> 
    <a href="/reset-password/">Forgot your password?</a> 
</body> 
</html> 

CSS

@charset "UTF-8" 
p { 
    color: red; 
} 
body { 
    margin: 0; 
} 

體餘量的變化,我可以改變文本的顏色,當我添加

color: red; 

身體。然而,不管我對'p'做什麼,都沒有發生。

我做錯了什麼,不會讓我編輯'p'標籤?

回答

1

這是一個很瑣碎的錯誤 - 你需要一個;第一行後:

@charset "UTF-8" 

應該

@charset "UTF-8"; 

這裏是the fiddle

+0

*捂臉*。該死的。這一直在困擾着我最後一個小時......謝謝你:D – Mathyou