麦子学院html与css里的侧栏怎么制作

html-css011

麦子学院html与css里的侧栏怎么制作,第1张

<div class="sidebar">

<ul>

<li>优先级

<ul>

<li><aonclickaonclick=""class="sidebar-selected">全部</a></li>

<li><aonclickaonclick="">P1</a></li>

<li><aonclickaonclick="">P2</a></li>

<li><aonclickaonclick=“" >P3</a></li>

<li><aonclickaonclick="">P4</a></li>

</ul>

</li>

</ul>

</div>

.sidebar {

border-right: 1px solid #f0f2f1

width: 180px

float: left

padding-left: 35px

}

.sidebar>ul {

list-style: none

padding: 0

margin: 0

}

.sidebar>ul>li {

font-size: 18px

font-weight: 400

padding: 0010px

margin-top: 5px

}

.sidebar>ul>li>ul {

border-top: 1px dashed rgba(0,0,0,0.1)

display: block

list-style: none

margin: 5px010px0

padding: 10px0010px

font-size: 14px

max-height: 138px

overflow: auto

}

.sidebar a {

line-height: 1.5

}

.sidebar a:hover {

color: #e74430

cursor:pointer

}

.sidebar-selected {

color: #e74430

}

1、先在你的app文件中新建一个文件夹static,再分别建立三个子文件夹js,style,images。

2、在settings.py中,加入:

STATIC_URL = '/static/'

STATICFILES_DIRS = (

os.path.join(BASE_DIR, "static"),

)

3、在html页面头部加入:

{% load staticfiles %}

<html>

<head>

<title>麦子学院</title>

</head>

<body>

4、

在html模版页面,可以用如下两种方式调用:

<img src="{% static 'images/logo.gif' %}" alt=""/>

<img src="/static/images/acer.gif" alt=""/>

推荐使用第二种,因为如果图片名称是动态的,可以通过views这么绑定:

<img src="/static/images/{{name}}.gif" alt=""/>

css的引用同样如此:

<link rel="stylesheet" href="{% static ‘style/base.css’ %}" type="text/css">

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

js的引用同样如此:

<script type="text/javascript" src="{% static ‘js/jquery-1.8.3.min.js' %}"/>

<script type="text/javascript" src="/static/js/jquery-1.8.3.min.js"/>