100

I know Bootstrap 3 has a horizontal divider you can place inside of dropdown menus to separate links like this:

<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu2">
  <li role="presentation" class="dropdown-header">Dropdown header</li>
   ...
  <li role="presentation" class="divider"></li>
</ul>

My question is: Is there any way to do this without it being in a dropdown, such as putting it into any kind of list or similar menu?

McVenco
  • 1,011
  • 1
  • 17
  • 30

3 Answers3

248

Yes there is, you can simply put <hr> in your code where you want it, I already use it in one of my admin panel side bar.

vog
  • 23,517
  • 11
  • 59
  • 75
  • 3
    `
    ` is even better.
    – Erwin Mayer Nov 21 '16 at 03:44
  • 22
    @ErwinMayer `
    ` is for XHTML. In HTML 4 or 5 it's just `
    `
    – Dave Dec 01 '16 at 20:42
  • 1
    It's an old reply, but for those who stumbled on here like i do,
    should not be used for presentation purpose like in OP case. It is for thematic change in paragraphs. Just like one should not use P tag to format controls.
    – KMC Feb 03 '20 at 20:03
17

Currently it only works for the .dropdown-menu:

.dropdown-menu .divider {
  height: 1px;
  margin: 9px 0;
  overflow: hidden;
  background-color: #e5e5e5;
}

If you want it for other use, in your own css, following the bootstrap.css create another one:

.divider {
  height: 1px;
  width:100%;
  display:block; /* for use on default inline elements like span */
  margin: 9px 0;
  overflow: hidden;
  background-color: #e5e5e5;
}
Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Christina
  • 34,296
  • 17
  • 83
  • 119
6

As I found the default Bootstrap <hr/> size unsightly, here's some simple HTML and CSS to balance out the element visually:

HTML:

<hr class="half-rule"/>

CSS:

.half-rule { 
    margin-left: 0;
    text-align: left;
    width: 50%;
 }
David Metcalfe
  • 2,237
  • 1
  • 31
  • 44