水平导航存在一些问题
我有一个带有水平导航的 Django 应用程序。由于某种原因,我在创建下拉菜单时遇到问题。
看看这两个图像
第一张图显示了水平导航。在图像的左侧,有一个菜单。 第二张图片显示了当我将鼠标悬停在存储订单上时(这是唯一具有下拉菜单的链接。)出于某种原因,选项卡的右侧似乎有点偏离。这是因为存储、传递和收集的标签长度因字数的不同而不同。如果可能的话,我想尝试使所有这三个选项卡的长度相同。
我遇到的另一个问题是,当我将光标移到存储订单上时,左侧菜单会向右移动。
base_menu.html
<ul id="toc">
<li id="current"><a href="{% url mmc.views.return_clients %}"><span>Home</span></a></li>
<li><a href="{% url mmc.views.quote_step1 %}"><span>Create quote/order</span></a></li>
<li><a href="{% url mmc.views.search_item %}"><span> Item Search</a></span></li>
<li><a href="{% url mmc.views.order_list %}"><span>Storage orders</span></a><br/>
<ul class="subnav">
<li><a href="{% url mmc.views.order_list_service 1 %}"><span>Delivery orders</span></a></li><br/>
<li><a href="{% url mmc.views.order_list_service 2 %}"><span>Collection orders</span></a></li>
</ul>
</li>
<li><a href="{% url mmc.views.service_list 1 %}"><span>Delivery list</span></a></li>
<li><a href="{% url mmc.views.service_list 2 %}"><span>Collection list</span></a></li>
<li><a href="{% url mmc.views.invoice_list %}"><span>Export for invoicing</span></a></li>
<li><a href="{% url mmc.views.dbbackup %}"><span>Backup data</span></a></li>
<li><a href="{% url mmc.views.help_index %}" target="_blank" onclick="return showAddAnotherPopup(this);"><span>Help</span></a></li>
</ul>
<br/>
base.css
ul#toc {
height: 2em;
list-style: none;
margin: 0;
padding: 0;
}
ul#toc li{
background:#ffffff url(../images/tab.png);
float: left;
margin: 0 1px 0 0;
}
ul#toc span {
background: url(../images/tab.png) 100% 0;
display: block;
line-height: 2em;
padding-right: 10px;
}
ul#toc a {
color: #000000;
height: 2em;
float: left;
text-decoration: none;
padding-left: 10px;
}
ul#toc a:hover {
background: url(../images/tab2.png);
text-decoration: underline;
}
ul#toc a:hover span {
background: url(../images/tab2.png) 100% 0;
background-position: 100% -120px;
}
ul.subnav {
float:left;
display:none;
position:absolute;
}
ul#toc li:hover .subnav {
display:block;
}
编辑: @Andres:
如果我进行更改,您可以从如下图所示,下拉选项卡需要再降低一点。另外,收藏选项卡也丢失了,但好处是左侧菜单不会向右移动。
更新 @Andres:我删除了模板中的
标签,使选项卡重新出现。现在使用 margin-top:10px 似乎有效。现在,从下图中,我需要确保我的下拉框可以与交付标头重叠。我想我可能已经完成了。
I have a django app that has a horizontal navigation. For some reason I am having problems creating a drop down menu.
Have a look at both of these images
The first image shows the horizontal navigation. On the left side of the image, there is a menu.
The second image shows when I hover over Storage orders (This is the only link that has a drop down menu.) For some reason the right hand side of the tab seems a bit off. This is because the length of the tab for storage, delivery and collection are different due to the number of words. I want to try to make all of these three tabs the same length if possible.
Another problem that I have is the left hand side menu moves to the right when I move my curser over storage orders.
base_menu.html
<ul id="toc">
<li id="current"><a href="{% url mmc.views.return_clients %}"><span>Home</span></a></li>
<li><a href="{% url mmc.views.quote_step1 %}"><span>Create quote/order</span></a></li>
<li><a href="{% url mmc.views.search_item %}"><span> Item Search</a></span></li>
<li><a href="{% url mmc.views.order_list %}"><span>Storage orders</span></a><br/>
<ul class="subnav">
<li><a href="{% url mmc.views.order_list_service 1 %}"><span>Delivery orders</span></a></li><br/>
<li><a href="{% url mmc.views.order_list_service 2 %}"><span>Collection orders</span></a></li>
</ul>
</li>
<li><a href="{% url mmc.views.service_list 1 %}"><span>Delivery list</span></a></li>
<li><a href="{% url mmc.views.service_list 2 %}"><span>Collection list</span></a></li>
<li><a href="{% url mmc.views.invoice_list %}"><span>Export for invoicing</span></a></li>
<li><a href="{% url mmc.views.dbbackup %}"><span>Backup data</span></a></li>
<li><a href="{% url mmc.views.help_index %}" target="_blank" onclick="return showAddAnotherPopup(this);"><span>Help</span></a></li>
</ul>
<br/>
base.css
ul#toc {
height: 2em;
list-style: none;
margin: 0;
padding: 0;
}
ul#toc li{
background:#ffffff url(../images/tab.png);
float: left;
margin: 0 1px 0 0;
}
ul#toc span {
background: url(../images/tab.png) 100% 0;
display: block;
line-height: 2em;
padding-right: 10px;
}
ul#toc a {
color: #000000;
height: 2em;
float: left;
text-decoration: none;
padding-left: 10px;
}
ul#toc a:hover {
background: url(../images/tab2.png);
text-decoration: underline;
}
ul#toc a:hover span {
background: url(../images/tab2.png) 100% 0;
background-position: 100% -120px;
}
ul.subnav {
float:left;
display:none;
position:absolute;
}
ul#toc li:hover .subnav {
display:block;
}
EDIT: @Andres:
If I make the change, you can see from the image below, the drop down tab needs to be lowered a bit more. Also, the collection tab is missing as well, but the good thing is the left hand menu does not shift to the right.
Update @Andres: I have removed the
tag in the template has made the tab re-appear. Now using margin-top:10px seem to work. Now from the image below, I need to make sure my drop-down box can overlap the delivery header. And I think I may be done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
因为你的 ul.subnav 类在弹出时仍然处于事物的流动中,所以它会移动底部的事物,如果你将它绝对定位,相对于父 li 它应该修复问题。
Try this:
since your
ul.subnav
class is still in the flow of things when it pops up it shifts things on the bottom, if you position it absolutely, relative to the parent li it should fix things up.