开发者

one of the pages doesnt inherit the css form the base

Hey, I am using django template. what below is a snippet from the base html file, I invoked css link

<link rel="stylesheet" type="text/css" href="static/css/layout.css"/>

but the weirdest thing happened.

{% extends "Layout.html" %}

all the html pages inherit from the base html file, but there is on开发者_如何学Ce page that doesnt inherit the css style while others work perfectly. anyone could think of a possible answer? Thank you in advance.


Don't hard code your css paths, if you are using the Django 1.3 staticfiles app, set the following in your settings.py:

STATIC_URL = '/static/'

In your template:

<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/layout.css"/>

I'm assuming that css/layout.css is present in the static folder of one of your app.


Here's a possible reason. This:

href="static/css/layout.css"

is relative to the current page. So if works for this URL:

http://mysite.com/page

then it will fail for this one:

http://mysite.com/subdirectory/deeper

You need to prefix the href with / (or the base URL of the site).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜