Fixed width buttons with Bootstrap

后端 未结 12 538
臣服心动
臣服心动 2021-01-29 18:36

Does Bootstrap support fixed width buttons? Currently if I have 2 buttons, \"Save\" and \"Download\", the button size changes based on content.

Also what is the right wa

12条回答
  •  孤街浪徒
    2021-01-29 19:10

    btn-group-justified and btn-group only work for static content but not on dynamically created buttons, and fixed with of button in css is not practical as it stay on the same width even all content are short.

    My solution: put the same class to group of buttons then loop to all of them, get the width of the longest button and apply it to all

    var bwidth=0
    $("button.btnGroup").each(function(i,v){
        if($(v).width()>bwidth) bwidth=$(v).width();
    });
    $("button.btnGroup").width(bwidth);
    

提交回复
热议问题