Create horizontally scrolling List Item view using Bootstrap Columns

前端 未结 3 1806
感动是毒
感动是毒 2020-12-06 04:48

I would like to display a number of records in a horizontally scrolling div. I\'m using Twitter Bootstrap and have setup a div row with each data record represented as a co

相关标签:
3条回答
  • 2020-12-06 05:41

    To allow horizontal scrolling check this github link

    Download and include bootstrap-horizon.css after bootstrap.css. as

    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/bootstrap-horizon.css">
    

    Sample code

    div class="row row-horizon">
      <div class="col-md-6">
        <h1>Test</h1>
      </div>
      <div class="col-md-6">
        <h1>Test</h1>
      </div>
      <div class="col-md-6">
        <h1>Test</h1>
      </div>
      <div class="col-md-6">
        <h1>Test</h1>
      </div>
    </div>`
    

    it works for me.

    0 讨论(0)
  • 2020-12-06 05:43

    Maybe this will help you:

    FIDDLE

    If the .DocumentItem width is fixed you can count the width of scroll element and set it dynamically.

    <script type="text/javascript">
        var totalWidth = $('.DocumentItem').length * $('.DocumentItem').width();
        $('.row').css('width', totalWidth + 'px');
    </script>
    
    0 讨论(0)
  • 2020-12-06 05:52

    I managed to get it working using almost stock Twitter Bootstrap:

    Fiddle: http://jsfiddle.net/V5zWT/12/

    I used an unordered list with the list-inline class. By default this will still wrap when it reaches the edge of the container, so I tweaked the list-inline class.

    .list-inline {
      white-space:nowrap;
    }
    
    <div class="DocumentList">
        <ul class="list-inline">
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
            <li class="DocumentItem">
                <span>Test Data1</span>
            </li>
        </ul>
    </div>
    
    0 讨论(0)
提交回复
热议问题