全宽Bootstrap下拉导航

编程入门 行业动态 更新时间:2024-10-11 19:25:41
本文介绍了全宽Bootstrap下拉导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用引导程序创建全宽下拉菜单,就像您在这张图片上看到的那样.现在我有了类似的东西(我从导航列表中删除了不必要的项目):

I'm trying to create full width dropdown using bootstrap as you can see on this picture. Now I have something like this (I have removed unnecessary items from the nav list):

<ul class="nav navbar-nav navbar-right"> <li> <a href="/_work/cz.krupovi/www/o-nas">O nás</a> </li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Kalkulačky <span class="caret"></span></a> <ul class="dropdown-menu list-inline" role="menu"> <li><a href="#">RPSN Kalkulačka</a> </li> <li><a href="#">Inflační kalkulačka</a> </li> </ul> </li> </ul>

我需要创建下拉列表.我没有对navbar进行任何更改,也没有删除更少的文件-这就是为什么我不发布CSS的原因,它是纯Bootstrap 3.2.0 .我只是在Chrome浏览器中玩过CSS规则,禁用了它们并更改了它们的值(这些值在定位方面很常见).

And I need to create dropdown like this one. I haven't done any changes to navbar and dropdown less files - this is the reason why I don't post CSS, it's pure Bootstrap 3.2.0. I just played with CSS rules in Chrome, disabled them and changed values of them (those that have something common with positioning).

添加了我自己的规则,但仍然无法弄清楚如何使其成为视口宽度的100%.可能是它从父级继承了宽度,而父级当然没有视口宽度.这可能是问题所在.

Added my own rules but still I can't figure out how to make it 100% of viewport width. Probably it inherits width from parent which - of course - doesn't have viewport width. This could be the problem.

也我找到了这个主题但这对我没有帮助.我当时在舞台上有大约800px的宽度下拉菜单(当我使用width: 100%时),但是它在Kalkulačky"下对齐,如果我希望它在屏幕的左边缘开始,则必须使用left: -100px.你有什么想法?我迷失了自己.

Also I have found this topic but it didn't help me. I was in stage where I got about 800px width dropdown (when I used width: 100%), but it was aligned under "Kalkulačky" and if I wanted it to start on the left edge of the screen I had to use left: -100px. Do you have any ideas? I'm competently lost.

请仁慈-我对CSS没有足够的了解,我只是从Bootstrap开始.

Please be benevolent - I don't have good knowledge in CSS and I just started with Bootstrap.

推荐答案

对于未包装在div.container中的默认导航栏组件,可以使用以下CSS:

For a default navbar component not wrapped in a div.container you can use the following CSS:

.nav > li.dropdown.open { position: static; } .nav > li.dropdown.open .dropdown-menu {display:table; width: 100%; text-align: center; left:0; right:0; } .dropdown-menu>li { display: table-cell; }

演示

display: table-cell也可以替换为display: inline-block;

更多推荐

全宽Bootstrap下拉导航

本文发布于:2023-11-23 04:11:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620041.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Bootstrap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!