How to display inline several
  • with 100% width?
  • 后端 未结 7 1347
    灰色年华
    灰色年华 2020-12-21 01:24

    I have the following html:

    • element 1
    • element 2
    <
    相关标签:
    7条回答
    • 2020-12-21 02:07

      using jquery to space your li's after your page has

        var ul = $('#yourListId');
        var numChildren = ul.children().length;
        if(numChildren <= 0){
          return;
        }
        ul.css({'list-style':'none','margin':0,'padding':0});
        var parentWidth = ul.width();
        var childWidth = parentWidth/numChildren;
        ul.children().each(function(index, value){
          $(this).css({'width':childWidth,'margin':0,'float':'left','display':'inline-block'});
        });
        ul.after('<div style="clear:both">');
      

      With the exception of the "childWidth" css... you can, of course, replace the other css with something from a style sheet.

      0 讨论(0)
    提交回复
    热议问题