Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap horizontal stacking of list-group

How can I make this look as a horizontal one line/row list seperated as vertical columns (instead of a set of rows with one column, as below) http://getbootstrap.com/components/#list-group-basic

<ul class="list-group">
  <li class="list-group-item">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
  <li class="list-group-item">Porta ac consectetur ac</li>
  <li class="list-group-item">Vestibulum at eros</li>
</ul>

Does it make sense to make use of http://getbootstrap.com/components/#with-button-elements in this case? Or should http://getbootstrap.com/components/#nav-disabled-links be used instead? I need the border seperation similar to list-group/list-group-item.

like image 555
Loser Coder Avatar asked Aug 13 '15 05:08

Loser Coder


People also ask

How do I make a horizontal ul list in bootstrap?

Horizontal List Groups. If you want the list items to display horizontally instead of vertically (side by side instead of on top of each other), add the . list-group-horizontal class to .

How you can add a badge to a list group in bootstrap?

Add the badges component to any list group item and it will automatically be positioned on the right. Just add <span class = "badge"> within the <li> element.

Can you enumerate the various lists supported by bootstrap?

The most basic list group is an unordered list with list items: First item. Second item. Third item.

How do I create an inline list in bootstrap?

Placing Ordered and Unordered List Items Inline. If you want to create a horizontal menu using the ordered or unordered list you need to place all list items in a single line (i.e. side by side). You can do this simply by adding the class . list-inline to the <ul> or <ol> , and the class .


3 Answers

You can set float: left to your li elements to make it horizontal in one line.

ul.list-group:after {
  clear: both;
  display: block;
  content: "";
}

.list-group-item {
    float: left;
}

Fiddle

Also from your given code I believe you don't need to make use of the #with-button-elements and #nav-disabled-links. The above example will do just fine.

like image 168
Robin Carlo Catacutan Avatar answered Oct 20 '22 02:10

Robin Carlo Catacutan


Just change your class list-group to list-inline. Everything else stays the exact same.

like image 27
Greg Johnson Avatar answered Oct 20 '22 00:10

Greg Johnson


For Bootstrap 4, replace list-group with d-flex flex-wrap.

https://jsfiddle.net/rd5my6hf/

like image 10
DharmaTurtle Avatar answered Oct 20 '22 01:10

DharmaTurtle