1

I'm trying to create a dropdown navbar using the latest version of Bootstrap. I'd like to create a dropdown where I have two separate lists in the dropdown, next to each other vertically (similar to the Air Purifiers dropdown on this website

It seems that Bootstrap only supports horizontal dividers at the moment. Does anyone know of a css/html hack I can use to get around this?

2 Answers 2

2

See this fiddle: http://jsfiddle.net/manishie/CVYq6/

Basically, you take the regular bootstrap dropdown and change it from a ul to a div. But you keep the class name the same. Within that div, you can have whatever you want.

In this case you want two side by side lists, but you could have images, or any html you want.

Bootstrap works off the class name, so that when you click the toggle, whatever is in the .dropdown-menu class will appear.

HTML:

<div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
  <div class="dropdown-menu" role="menu">
      <ul>
          <li>one</li>
          <li>two</li>
          <li>three</li>
          <li>four</li>
      </ul>
      <ul>
          <li>blah</li>
          <li>blah blah</li>
          <li>blah blah blah</li>
      </ul>
  </div>
</div>​

CSS:

.dropdown-menu ul {
    float: left;
}

.dropdown-menu ul:first-of-type {
    border-right: 1px solid black;
    padding-right:20px
}
​
Sign up to request clarification or add additional context in comments.

2 Comments

funny aria-labelledby="dLabel" references a label not shown either here or at fiddle :)
Good point. I copied some code from the bootstrap site and modified it to answer the question. That got left in there somehow. I've removed it and updated my answer. Thanks!
0

I believe this functionality does not exist yet out of the box.

Related issue on github.

You can try to hack it and manually inject columns or just do it without using bootstrap at all.

If you need this for a menu you can try mega menu or flexbox

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.