How do I use Bootstrap columns inside a list item?

redtree

Consider the following markup with Boostrap 3:

<ol>
    <li>
        <div class="row">
            <div class="col-xs-6">
                Row 1, col 1
            </div>
            <div class="col-xs-6">
                Row 1, col 2
            </div>
        </div>
    </li>
</ol>

Why does the text not align with the "1." from the <ol>? See http://jsfiddle.net/R2tXU/ as an example...

Also, would it be valid to put the class="row" right on the <li>?

Thanks!

user1960364

Sorry, I'm a little late responding here... However, using valid markup is important and therefore I think it's worth mentioning alternative solutions...

Option 1

Using a little HTML and CSS, you could set the value on each li ([ Valid HTML5 ]):

[ JS Fiddle Example ]

HTML

<ol>
    <li class="col-xs-6" value="1">Row 1, col 1</li>
    <li class="col-xs-6">Row 1, col 2</li>
    <li class="col-xs-6" value="2">Row 2, col 1</li>
    <li class="col-xs-6">Row 2, col 2</li>
</ol>

CSS

ol li:nth-child(2n+0) {
    list-style: none;
}

Option 2

However, if you're going for a purely CSS approach, this is probably the best option...

[ JSFiddle Example ]

HTML

<ol>
    <li class="col-xs-6">Row 1, col 1</li>
    <li class="col-xs-6">Row 1, col 2</li>
    <li class="col-xs-6">Row 2, col 1</li>
    <li class="col-xs-6">Row 2, col 2</li>
</ol>

CSS

ol {
    counter-reset: index;
}

ol li:nth-child(2n+0) {
    counter-increment: index;
    list-style: none;
}

ol li:nth-child(2n+0):before {
    content: counter(index) ".";
}

ol li:nth-child(2n+0):before {
    content: "";
}

However, do keep in mind [ browser compatibility ].

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I align values inside my listview list item?

From Dev

How do I align values inside my listview list item?

From Dev

How do I use Bootstrap modal in HTML table inside JavaScript?

From Dev

How do I use list monad inside of ReaderT?

From Dev

How do I use a CheckBoxFor inside a foreach when working with a list?

From Dev

How do I use list monad inside of ReaderT?

From Dev

How do I get the id of a list item?

From Dev

How do I navigate between List and Item?

From Dev

How do I modify a list inside a thread?

From Dev

How do I split my list into columns

From Dev

How do I use CSS in ion-list, ion-item

From Dev

How do I use CSS in ion-list, ion-item

From Dev

Bootstrap Rows and Columns - Do I need to use row?

From Dev

How do I use await inside a generator?

From Dev

How do I use colorama inside a tuple?

From Dev

Angular: How can I access and modify an item inside a scope list?

From Dev

How do I use list indices to return columns of data instead of rows?

From Dev

In React Native (and Ignite), how do I create a ListView (inside a tab) that navigates to another container when a list item is clicked?

From Dev

How do I align an item to the right inside a flex container?

From Dev

how do i update listview item index inside thread

From Dev

How do I align an item to the right inside a flex container?

From Dev

How do I remove the last item of an array inside of an array

From Dev

How do I search for a vault item from inside a recipe?

From Dev

How do I generate a list for each list item

From Dev

How do I generate a list for each list item

From Dev

How i can use Bootstrap Popover inside a submit button?

From Dev

How can i use margin and padding inside of bootstrap?

From Dev

how do i create a two list from a list inside of an array?

From Dev

how do i add bootstrap image inside a mvc actionlink syntax?

Related Related

  1. 1

    How do I align values inside my listview list item?

  2. 2

    How do I align values inside my listview list item?

  3. 3

    How do I use Bootstrap modal in HTML table inside JavaScript?

  4. 4

    How do I use list monad inside of ReaderT?

  5. 5

    How do I use a CheckBoxFor inside a foreach when working with a list?

  6. 6

    How do I use list monad inside of ReaderT?

  7. 7

    How do I get the id of a list item?

  8. 8

    How do I navigate between List and Item?

  9. 9

    How do I modify a list inside a thread?

  10. 10

    How do I split my list into columns

  11. 11

    How do I use CSS in ion-list, ion-item

  12. 12

    How do I use CSS in ion-list, ion-item

  13. 13

    Bootstrap Rows and Columns - Do I need to use row?

  14. 14

    How do I use await inside a generator?

  15. 15

    How do I use colorama inside a tuple?

  16. 16

    Angular: How can I access and modify an item inside a scope list?

  17. 17

    How do I use list indices to return columns of data instead of rows?

  18. 18

    In React Native (and Ignite), how do I create a ListView (inside a tab) that navigates to another container when a list item is clicked?

  19. 19

    How do I align an item to the right inside a flex container?

  20. 20

    how do i update listview item index inside thread

  21. 21

    How do I align an item to the right inside a flex container?

  22. 22

    How do I remove the last item of an array inside of an array

  23. 23

    How do I search for a vault item from inside a recipe?

  24. 24

    How do I generate a list for each list item

  25. 25

    How do I generate a list for each list item

  26. 26

    How i can use Bootstrap Popover inside a submit button?

  27. 27

    How can i use margin and padding inside of bootstrap?

  28. 28

    how do i create a two list from a list inside of an array?

  29. 29

    how do i add bootstrap image inside a mvc actionlink syntax?

HotTag

Archive