Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap horizontal dropdown-menu?

I'd like a bootstrap dropdown menu where the links are horizontal. Unfortunately, I'm having trouble with getting the width correct. The only way I can seem to make it happen is set the min-width to some arbitrary number. I'd like to do this responsively.

enter image description here

http://jsfiddle.net/3CwzH/

@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.dropdown-menu>li>a {
  display: inline;
}

.dropdown-menu {
  min-width: 500px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="btn-group">
  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
        Drop it
      </button>
  <ul class="dropdown-menu" role="menu">
    <li>
      <a href="http://google.com">Google</a>
      <a href="http://facebook.com">Facebook</a>
    </li>
  </ul>
</div>
like image 965
John Avatar asked Dec 04 '22 06:12

John


1 Answers

I have solved your problem. View this JSFiddle for demonstration.

HTML

    <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Drop it</button>
    <ul class="dropdown-menu" role="menu">
        <li> <a href="http://google.com">Google</a>

        </li>
        <li> <a href="http://facebook.com">Facebook</a>

        </li>
    </ul>
</div>

CSS

 @import url('http://getbootstrap.com/dist/css/bootstrap.css');
 .dropdown-menu > li {
    display: inline-block;
    float:left;
}
.open > ul {
    display: inline-flex !important;
}
like image 53
Suresh Karia Avatar answered Dec 30 '22 06:12

Suresh Karia