Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce Bootstrap list width

I am creating a list and styling it with Bootstrap. The HTML looks something like this:

<div class="list-group">
    <a href="/link" class="list-group-item list-group-item-success">Name</a>
    <a href="/link" class="list-group-item list-group-item-danger">Name</a>
</div>

When this displays, the list elements take up the whole page.screenshot of HTML

If not for the coloring, this would not be a big deal. How can I make the list elements stretch only as far as the text? Thanks!

like image 271
Alex Parker Avatar asked Jan 04 '23 22:01

Alex Parker


1 Answers

try adding style display:inline-block to the .list-group

.list-group{
      display:inline-block;
 }

<div class="list-group">
    <a href="/link" class="list-group-item list-group-item-success">Name</a>
    <a href="/link" class="list-group-item list-group-item-danger">Name</a>
</div>
like image 60
XYZ Avatar answered Jan 06 '23 12:01

XYZ