S7H*_*S7H 5 html css django django-templates
我有一个 css 文件,我想在其中导入另一个 css 文件。我怎样才能在 Django 中做到这一点?
这是我的 style.css 文件,我想在其中导入 owl.carousel.css 。
@import url("owl.carousel.css");
body {
margin: 0;
padding: 0;
color: #34495E;
font-family: 'Source Sans Pro', sans-serif;
font-size: 14px;
line-height: 21px;
position: relative;
background: #fff;
}
Run Code Online (Sandbox Code Playgroud)
我在模板上使用 {% load static %} 来链接 style.css 但如何在 css 中导入 css ?
<link href="{% static "assets/css/style.css" %}" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)
如果你想.css在 a 中导入文件,.css你将需要像往常一样使用路径。
@import url('/path/to/your/file.css')
Run Code Online (Sandbox Code Playgroud)
如果它们位于静态文件夹中:
static/styles/file1.css
static/styles/file2.css
/* in file2.css */
@import url('file1.css')
Run Code Online (Sandbox Code Playgroud)
无法在.css文件内使用 django 模板语言。