Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two Columns Bulleted Lists in responsive twitter bootstrap

This is my first foray into Twitter Bootstrap. Take a look at this template here: http://twitter.github.com/bootstrap/examples/hero.html

Underneath one of the headings, I'd like to break a long ul into two columns:

*item1 *item4
*item2 *item5
*item3 *item6

It can be two separate <ul>s in the code, it just needs to look like two bulleted columns next to each other.

Can someone recommend a method to me? My problem so far is keeping it responsive to screen size so on narrows screens the two separate lists somewhat stack on each other again.

Thanks!

like image 247
Jonathan S. Fisher Avatar asked Jun 26 '12 02:06

Jonathan S. Fisher


People also ask

What is Col SM 4 in Bootstrap?

col-sm-4 are available for quickly making grid layouts. Columns create gutters (gaps between column content) via padding. That padding is offset in rows for the first and last column via negative margin on .

How do I split a row into 5 columns in Bootstrap?

You can use the row-cols-* (eg: row-cols-3 , row-cols-md-3 ) class for your requirement. Save this answer.

What is XS SM MD lg in Bootstrap?

The Bootstrap 3 grid system has four tiers of classes: xs (phones), sm (tablets), md (desktops), and lg (larger desktops). You can use nearly any combination of these classes to create more dynamic and flexible layouts.


2 Answers

I would use a fluid grid system inside the span4 div tag. Check out the fluid grid system here... http://getbootstrap.com/css/#grid

Using this method, the lists will stack on each other again when the screen is small.

Here's an example...

<html>
<head>
    <title></title>
    <link href="css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
        <div class="container">
            <div class="row">
                <div class="span4">
                    <h4>Column 1</h4>
                    <div class="container-fluid">
                        <div class="row-fluid">
                            <div class="span6">
                                <ul>
                                    <li>Item 1</li>
                                    <li>Item 2</li>
                                    <li>Item 3</li>
                                </ul>
                            </div>
                            <div class="span6">
                                <ul>
                                    <li>Item 4</li>
                                    <li>Item 5</li>
                                    <li>Item 6</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="span4">
                    <h4>Column 2</h4>
                </div>
                <div class="span4">
                    <h4>Column 3</h4>
                </div>
            </div>
        </div>
</body>
</html>
like image 83
Theo Avatar answered Nov 03 '22 01:11

Theo


this should help in case you have one ul an many li's

css

  @media (min-width:768px) { 
    .col2{ width:100%;}
    .col2 li{width:49%; float:left;}
  }

html(haml)

  .box-body      
    .row-fluid
      %ul.col2.clearfix
       [email protected] do |category|
         %li
         =category.title 
like image 23
Caner Avatar answered Nov 03 '22 02:11

Caner