【发布时间】:2015-06-13 01:49:51
【问题描述】:
您好,我知道这个问题被问了很多次,我尝试了很多解决方案,但它对我没有用。因此,我想发布这个问题以寻求帮助。 我有一个 django 应用程序,它在 bootstrap 的帮助下完成了一些 html 模板。现在我希望其中一个 div 完全隐藏(当它被隐藏时,一个图标应该出现在侧边栏的位置)并在点击图标时显示左侧菜单栏。 这是我的html文件
{% load staticfiles %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>**</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet" media="screen">
<link href="{% static 'bootstrap/css/dashboard.css' %}" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
<link href="{% static 'style.css' %}" rel="stylesheet">
<script src='http://codepen.io/assets/libs/fullpage/jquery.js'></script>
</head>
<body>
{% block content %}
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="http://www.google.com/"><img src="{% static "bootstrap/css/logo4.png" %}" alt="MPOWER" style="margin-top:-5%;"/></a>
</div>
<div>
<ul class="nav navbar-nav navbar-right">
<li></li>
<li><a href="#"><span class="glyphicon glyphicon-user"></span> {% if user.is_authenticated %}
{{ user.first_name }}
{{ request.user.username }}</a></li>
{% endif %}
<li><a href="{% url 'django.contrib.auth.views.logout' %}"><span class="glyphicon glyphicon-log-out\"></span>Logout</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid" >
<div id="overlay"></div>
<div class="row">
<div class="col-sm-3 col-md-2 sidebar" id="mobile-menu">
<ul class="nav nav-sidebar">
<li><a href="#"><span id="menu-button"><span class="glyphicon glyphicon-chevron-right"></span></span></a></li>
<li><span style="color:blue; font-weight:bold;">Dashboardsssss</span></li>
{% for Dashboard in dashboards %}
<li><a href="{{ Dashboard.d_url }}" target="iframe_a">{{ Dashboard.d_name }}</a></li>
{% endfor %}
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" style="height:600px; margin-top:4%;">
<iframe width="100%" height="95%" name="iframe_a" frameborder="0"></iframe>
</div>
</div>
</div>
<script src='http://codepen.io/assets/libs/fullpage/jquery.js'></script>
<script src="{% static 'index.js' %}"></script>
{% endblock %}
</body>
</html
在上面的 html 页面中,我希望在每次单击时显示和隐藏此 div,并且它应该在同一菜单栏上有一个图标来执行此操作。 注意:图标应始终可见。 请帮我做这个功能。 提前致谢。 而css看起来像
#main_header .panel_btn {
display: block;
position: absolute;
left: 15px;
top: 15px;
height: 20px;
width: 20px;
background: rgb(200,200,200);
z-index: 5;
}
#main_header .panel_btn .line {
display: block;
position: relative;
height: 4px;
margin-bottom: 4px;
background: rgb(80,80,80);
}
#main_header .panel_btn .line:last-child {
margin-bottom: 0px;
}
.navbar-fixed-top {
border: 0;
}
/*
* Sidebar
*/
/* Hide for mobile, show later */
.sidebar {
display: none;
}
@media (min-width: 768px) {
.sidebar {
position: fixed;
top: 51px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px;
overflow-x: hidden;
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
background-color: #f5f5f5;
}
}
/* Sidebar navigation */
.nav-sidebar {
margin-right: -21px; /* 20px padding + 1px border */
margin-bottom: 20px;
margin-left: -20px;
}
.nav-sidebar > li > a {
padding-right: 20px;
padding-left: 20px;
}
.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus {
color: #fff;
background-color: #428bca;
}
/*
* Main content
*/
【问题讨论】:
-
片段意味着 HTML 和 CSS 连接在一起,而不是分开的。
-
@Blake 我确实使用链接 rel 将我的 css 链接到 html
-
不,我的意思是在你的问题中,你需要在你的 sn-p 中有你的 CSS 和 HTML。我会编辑你的帖子..
-
@Blake,是的,我明白了,现在如何获得我需要的功能。
-
HTML 中的“{”是什么意思?是用于引导代码吗?
标签: javascript html css django-templates