Justify buttons with Bootstrap v4





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







29















Bootstrap v4 drops the .btn-group-justified class, see https://github.com/twbs/bootstrap/issues/17631



How to justify the button for:



 <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
<a class="btn btn-primary" href="#" role="button">Left</a>
<a class="btn btn-primary" href="#" role="button">Middle</a>
<a class="btn btn-primary" href="#" role="button">Right</a>
</div>









share|improve this question































    29















    Bootstrap v4 drops the .btn-group-justified class, see https://github.com/twbs/bootstrap/issues/17631



    How to justify the button for:



     <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
    <a class="btn btn-primary" href="#" role="button">Left</a>
    <a class="btn btn-primary" href="#" role="button">Middle</a>
    <a class="btn btn-primary" href="#" role="button">Right</a>
    </div>









    share|improve this question



























      29












      29








      29


      8






      Bootstrap v4 drops the .btn-group-justified class, see https://github.com/twbs/bootstrap/issues/17631



      How to justify the button for:



       <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
      <a class="btn btn-primary" href="#" role="button">Left</a>
      <a class="btn btn-primary" href="#" role="button">Middle</a>
      <a class="btn btn-primary" href="#" role="button">Right</a>
      </div>









      share|improve this question
















      Bootstrap v4 drops the .btn-group-justified class, see https://github.com/twbs/bootstrap/issues/17631



      How to justify the button for:



       <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
      <a class="btn btn-primary" href="#" role="button">Left</a>
      <a class="btn btn-primary" href="#" role="button">Middle</a>
      <a class="btn btn-primary" href="#" role="button">Right</a>
      </div>






      css bootstrap-4 twitter-bootstrap-4






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 12 '17 at 6:58









      Eduardo Yáñez Parareda

      3,09522437




      3,09522437










      asked Dec 24 '15 at 9:39









      Bass JobsenBass Jobsen

      44k14126209




      44k14126209
























          4 Answers
          4






          active

          oldest

          votes


















          51














          For anyone finding this after Bootstrap 4 Beta was released...






          <div class="btn-group d-flex" role="group">
          <a href="" class="btn btn-secondary w-100">Previous</a>
          <a href="" class="btn btn-secondary w-100">Next</a>
          </div>








          share|improve this answer
























          • Thanks, that's what I was looking for... I think I must learn more about flex styles in Bootstrap 4

            – Eduardo Yáñez Parareda
            Oct 12 '17 at 6:57






          • 3





            Should be first answer, no need for custom CSS, less hacky. Well done!

            – Eduardo
            Nov 6 '17 at 13:32



















          21














          Indeed the nav-justify class is missing. You can add it yourself based on TB3's code for now:



          SCSS code



          // Justified button groups
          // ----------------------

          .btn-group-justified {
          display: table;
          width: 100%;
          table-layout: fixed;
          border-collapse: separate;
          .btn,
          .btn-group {
          float: none;
          display: table-cell;
          width: 1%;
          .btn {
          width: 100%;
          }
          .dropdown-menu {
          left: auto;
          }
          }
          }


          compiled CSS code



          .btn-group-justified {
          display: table;
          width: 100%;
          table-layout: fixed;
          border-collapse: separate; }
          .btn-group-justified .btn,
          .btn-group-justified .btn-group {
          float: none;
          display: table-cell;
          width: 1%; }
          .btn-group-justified .btn .btn,
          .btn-group-justified .btn-group .btn {
          width: 100%; }
          .btn-group-justified .btn .dropdown-menu,
          .btn-group-justified .btn-group .dropdown-menu {
          left: auto; }


          HTML



           <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
          <a class="btn btn-primary" href="#" role="button">Left</a>
          <a class="btn btn-primary" href="#" role="button">Middle</a>
          <a class="btn btn-primary" href="#" role="button">Right</a>
          </div>


          The above HTML code now will look like that shown in the figure beneath:



          enter image description here



          Handling borders




          • Due to the specific HTML and CSS used to justify buttons (namely display: table-cell), the borders between them are doubled. In regular button groups, margin-left: -1px is used to stack the borders instead of removing them. However, margin doesn't work with display: table-cell. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.


          Links acting as buttons




          • If the <a> elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button".


          Dropdowns



          Use the following HTML code for dropdown buttons:



           <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group with nested dropdown">
          <a class="btn btn-secondary" href="#" role="button">Left</a>
          <a class="btn btn-secondary" href="#" role="button">Middle</a>
          <div class="btn-group">
          <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Action
          </button>
          <div class="dropdown-menu">
          <a class="dropdown-item" href="#">Action</a>
          <a class="dropdown-item" href="#">Another action</a>
          <a class="dropdown-item" href="#">Something else here</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="#">Separated link</a>
          </div>
          </div>
          </div>


          The justified button group with dropdown button should look like that shown in the figure below:



          enter image description here



          With <button> elements




          • To use justified button groups with <button> elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to <button> elements, but since we support button dropdowns, we can work around that.


          HTML



           <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
          <div class="btn-group" role="group">
          <button type="button" class="btn btn-secondary">Left</button>
          </div>
          <div class="btn-group" role="group">
          <button type="button" class="btn btn-secondary">Middle</button>
          </div>
          <div class="btn-group" role="group">
          <button type="button" class="btn btn-secondary">Right</button>
          </div>
          </div>


          The above HTML code used to justified button groups with <button> elements should look like that shown in the figure beneath:



          enter image description here






          share|improve this answer
























          • why set the width of the btn to 1% within the btn-group? Is this intended?

            – luQ
            Oct 18 '17 at 12:54





















          20














          Building on Bass Jobsen's great answer, here is the same functionality using flexbox instead of display: table;



          SCSS code



          // Justified button groups
          // ----------------------

          .btn-group-justified {
          display: flex;
          width: 100%;
          .btn,
          .btn-group {
          flex: 1;
          .btn {
          width: 100%;
          }
          .dropdown-menu {
          left: auto;
          }
          }
          }


          HTML



          <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
          <a class="btn btn-primary" href="#" role="button">Left</a>
          <a class="btn btn-primary" href="#" role="button">Middle</a>
          <a class="btn btn-primary" href="#" role="button">Right</a>
          </div>


          Please refer to Bass Jobsen's answer for more details on usage with dropdowns, HTML Links and more.






          share|improve this answer


























          • Excellent, it also avoids the double-border issue

            – Giuseppe
            Aug 25 '16 at 7:55











          • Suggestion: add & + & {margin-top: $btn-block-spacing-y;} to space out stacked justified button groups

            – Chris Barr
            Nov 28 '16 at 0:32





















          0














          When using with class="dropdown-menu" with Bootstrap V4.0, based on Chris Baswell' solution above and Bootstrap Documentation: https://getbootstrap.com/docs/4.0/components/button-group/#nesting



          <div class="btn-group d-flex" role="group">
          <button type="button" class="btn btn-secondary">1</button>
          <button type="button" class="btn btn-secondary">2</button>
          <div class="btn-group w-100" role="group">
          <button type="button" class="btn btn-secondary dropdown-toggle-no-carret w-100" title="MANAGE ENTRIES" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Drop Down
          </button>
          <div class="dropdown-menu">
          <a href="" class="btn btn-secondary w-100">Previous</a>
          <a href="" class="btn btn-secondary w-100">Next</a>
          </div>
          </div>
          </div>





          share|improve this answer


























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34450586%2fjustify-buttons-with-bootstrap-v4%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            51














            For anyone finding this after Bootstrap 4 Beta was released...






            <div class="btn-group d-flex" role="group">
            <a href="" class="btn btn-secondary w-100">Previous</a>
            <a href="" class="btn btn-secondary w-100">Next</a>
            </div>








            share|improve this answer
























            • Thanks, that's what I was looking for... I think I must learn more about flex styles in Bootstrap 4

              – Eduardo Yáñez Parareda
              Oct 12 '17 at 6:57






            • 3





              Should be first answer, no need for custom CSS, less hacky. Well done!

              – Eduardo
              Nov 6 '17 at 13:32
















            51














            For anyone finding this after Bootstrap 4 Beta was released...






            <div class="btn-group d-flex" role="group">
            <a href="" class="btn btn-secondary w-100">Previous</a>
            <a href="" class="btn btn-secondary w-100">Next</a>
            </div>








            share|improve this answer
























            • Thanks, that's what I was looking for... I think I must learn more about flex styles in Bootstrap 4

              – Eduardo Yáñez Parareda
              Oct 12 '17 at 6:57






            • 3





              Should be first answer, no need for custom CSS, less hacky. Well done!

              – Eduardo
              Nov 6 '17 at 13:32














            51












            51








            51







            For anyone finding this after Bootstrap 4 Beta was released...






            <div class="btn-group d-flex" role="group">
            <a href="" class="btn btn-secondary w-100">Previous</a>
            <a href="" class="btn btn-secondary w-100">Next</a>
            </div>








            share|improve this answer













            For anyone finding this after Bootstrap 4 Beta was released...






            <div class="btn-group d-flex" role="group">
            <a href="" class="btn btn-secondary w-100">Previous</a>
            <a href="" class="btn btn-secondary w-100">Next</a>
            </div>








            <div class="btn-group d-flex" role="group">
            <a href="" class="btn btn-secondary w-100">Previous</a>
            <a href="" class="btn btn-secondary w-100">Next</a>
            </div>





            <div class="btn-group d-flex" role="group">
            <a href="" class="btn btn-secondary w-100">Previous</a>
            <a href="" class="btn btn-secondary w-100">Next</a>
            </div>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 30 '17 at 20:22









            Chris BaswellChris Baswell

            511133




            511133













            • Thanks, that's what I was looking for... I think I must learn more about flex styles in Bootstrap 4

              – Eduardo Yáñez Parareda
              Oct 12 '17 at 6:57






            • 3





              Should be first answer, no need for custom CSS, less hacky. Well done!

              – Eduardo
              Nov 6 '17 at 13:32



















            • Thanks, that's what I was looking for... I think I must learn more about flex styles in Bootstrap 4

              – Eduardo Yáñez Parareda
              Oct 12 '17 at 6:57






            • 3





              Should be first answer, no need for custom CSS, less hacky. Well done!

              – Eduardo
              Nov 6 '17 at 13:32

















            Thanks, that's what I was looking for... I think I must learn more about flex styles in Bootstrap 4

            – Eduardo Yáñez Parareda
            Oct 12 '17 at 6:57





            Thanks, that's what I was looking for... I think I must learn more about flex styles in Bootstrap 4

            – Eduardo Yáñez Parareda
            Oct 12 '17 at 6:57




            3




            3





            Should be first answer, no need for custom CSS, less hacky. Well done!

            – Eduardo
            Nov 6 '17 at 13:32





            Should be first answer, no need for custom CSS, less hacky. Well done!

            – Eduardo
            Nov 6 '17 at 13:32













            21














            Indeed the nav-justify class is missing. You can add it yourself based on TB3's code for now:



            SCSS code



            // Justified button groups
            // ----------------------

            .btn-group-justified {
            display: table;
            width: 100%;
            table-layout: fixed;
            border-collapse: separate;
            .btn,
            .btn-group {
            float: none;
            display: table-cell;
            width: 1%;
            .btn {
            width: 100%;
            }
            .dropdown-menu {
            left: auto;
            }
            }
            }


            compiled CSS code



            .btn-group-justified {
            display: table;
            width: 100%;
            table-layout: fixed;
            border-collapse: separate; }
            .btn-group-justified .btn,
            .btn-group-justified .btn-group {
            float: none;
            display: table-cell;
            width: 1%; }
            .btn-group-justified .btn .btn,
            .btn-group-justified .btn-group .btn {
            width: 100%; }
            .btn-group-justified .btn .dropdown-menu,
            .btn-group-justified .btn-group .dropdown-menu {
            left: auto; }


            HTML



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <a class="btn btn-primary" href="#" role="button">Left</a>
            <a class="btn btn-primary" href="#" role="button">Middle</a>
            <a class="btn btn-primary" href="#" role="button">Right</a>
            </div>


            The above HTML code now will look like that shown in the figure beneath:



            enter image description here



            Handling borders




            • Due to the specific HTML and CSS used to justify buttons (namely display: table-cell), the borders between them are doubled. In regular button groups, margin-left: -1px is used to stack the borders instead of removing them. However, margin doesn't work with display: table-cell. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.


            Links acting as buttons




            • If the <a> elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button".


            Dropdowns



            Use the following HTML code for dropdown buttons:



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group with nested dropdown">
            <a class="btn btn-secondary" href="#" role="button">Left</a>
            <a class="btn btn-secondary" href="#" role="button">Middle</a>
            <div class="btn-group">
            <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Action
            </button>
            <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
            </div>
            </div>
            </div>


            The justified button group with dropdown button should look like that shown in the figure below:



            enter image description here



            With <button> elements




            • To use justified button groups with <button> elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to <button> elements, but since we support button dropdowns, we can work around that.


            HTML



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Left</button>
            </div>
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Middle</button>
            </div>
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Right</button>
            </div>
            </div>


            The above HTML code used to justified button groups with <button> elements should look like that shown in the figure beneath:



            enter image description here






            share|improve this answer
























            • why set the width of the btn to 1% within the btn-group? Is this intended?

              – luQ
              Oct 18 '17 at 12:54


















            21














            Indeed the nav-justify class is missing. You can add it yourself based on TB3's code for now:



            SCSS code



            // Justified button groups
            // ----------------------

            .btn-group-justified {
            display: table;
            width: 100%;
            table-layout: fixed;
            border-collapse: separate;
            .btn,
            .btn-group {
            float: none;
            display: table-cell;
            width: 1%;
            .btn {
            width: 100%;
            }
            .dropdown-menu {
            left: auto;
            }
            }
            }


            compiled CSS code



            .btn-group-justified {
            display: table;
            width: 100%;
            table-layout: fixed;
            border-collapse: separate; }
            .btn-group-justified .btn,
            .btn-group-justified .btn-group {
            float: none;
            display: table-cell;
            width: 1%; }
            .btn-group-justified .btn .btn,
            .btn-group-justified .btn-group .btn {
            width: 100%; }
            .btn-group-justified .btn .dropdown-menu,
            .btn-group-justified .btn-group .dropdown-menu {
            left: auto; }


            HTML



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <a class="btn btn-primary" href="#" role="button">Left</a>
            <a class="btn btn-primary" href="#" role="button">Middle</a>
            <a class="btn btn-primary" href="#" role="button">Right</a>
            </div>


            The above HTML code now will look like that shown in the figure beneath:



            enter image description here



            Handling borders




            • Due to the specific HTML and CSS used to justify buttons (namely display: table-cell), the borders between them are doubled. In regular button groups, margin-left: -1px is used to stack the borders instead of removing them. However, margin doesn't work with display: table-cell. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.


            Links acting as buttons




            • If the <a> elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button".


            Dropdowns



            Use the following HTML code for dropdown buttons:



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group with nested dropdown">
            <a class="btn btn-secondary" href="#" role="button">Left</a>
            <a class="btn btn-secondary" href="#" role="button">Middle</a>
            <div class="btn-group">
            <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Action
            </button>
            <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
            </div>
            </div>
            </div>


            The justified button group with dropdown button should look like that shown in the figure below:



            enter image description here



            With <button> elements




            • To use justified button groups with <button> elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to <button> elements, but since we support button dropdowns, we can work around that.


            HTML



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Left</button>
            </div>
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Middle</button>
            </div>
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Right</button>
            </div>
            </div>


            The above HTML code used to justified button groups with <button> elements should look like that shown in the figure beneath:



            enter image description here






            share|improve this answer
























            • why set the width of the btn to 1% within the btn-group? Is this intended?

              – luQ
              Oct 18 '17 at 12:54
















            21












            21








            21







            Indeed the nav-justify class is missing. You can add it yourself based on TB3's code for now:



            SCSS code



            // Justified button groups
            // ----------------------

            .btn-group-justified {
            display: table;
            width: 100%;
            table-layout: fixed;
            border-collapse: separate;
            .btn,
            .btn-group {
            float: none;
            display: table-cell;
            width: 1%;
            .btn {
            width: 100%;
            }
            .dropdown-menu {
            left: auto;
            }
            }
            }


            compiled CSS code



            .btn-group-justified {
            display: table;
            width: 100%;
            table-layout: fixed;
            border-collapse: separate; }
            .btn-group-justified .btn,
            .btn-group-justified .btn-group {
            float: none;
            display: table-cell;
            width: 1%; }
            .btn-group-justified .btn .btn,
            .btn-group-justified .btn-group .btn {
            width: 100%; }
            .btn-group-justified .btn .dropdown-menu,
            .btn-group-justified .btn-group .dropdown-menu {
            left: auto; }


            HTML



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <a class="btn btn-primary" href="#" role="button">Left</a>
            <a class="btn btn-primary" href="#" role="button">Middle</a>
            <a class="btn btn-primary" href="#" role="button">Right</a>
            </div>


            The above HTML code now will look like that shown in the figure beneath:



            enter image description here



            Handling borders




            • Due to the specific HTML and CSS used to justify buttons (namely display: table-cell), the borders between them are doubled. In regular button groups, margin-left: -1px is used to stack the borders instead of removing them. However, margin doesn't work with display: table-cell. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.


            Links acting as buttons




            • If the <a> elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button".


            Dropdowns



            Use the following HTML code for dropdown buttons:



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group with nested dropdown">
            <a class="btn btn-secondary" href="#" role="button">Left</a>
            <a class="btn btn-secondary" href="#" role="button">Middle</a>
            <div class="btn-group">
            <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Action
            </button>
            <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
            </div>
            </div>
            </div>


            The justified button group with dropdown button should look like that shown in the figure below:



            enter image description here



            With <button> elements




            • To use justified button groups with <button> elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to <button> elements, but since we support button dropdowns, we can work around that.


            HTML



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Left</button>
            </div>
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Middle</button>
            </div>
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Right</button>
            </div>
            </div>


            The above HTML code used to justified button groups with <button> elements should look like that shown in the figure beneath:



            enter image description here






            share|improve this answer













            Indeed the nav-justify class is missing. You can add it yourself based on TB3's code for now:



            SCSS code



            // Justified button groups
            // ----------------------

            .btn-group-justified {
            display: table;
            width: 100%;
            table-layout: fixed;
            border-collapse: separate;
            .btn,
            .btn-group {
            float: none;
            display: table-cell;
            width: 1%;
            .btn {
            width: 100%;
            }
            .dropdown-menu {
            left: auto;
            }
            }
            }


            compiled CSS code



            .btn-group-justified {
            display: table;
            width: 100%;
            table-layout: fixed;
            border-collapse: separate; }
            .btn-group-justified .btn,
            .btn-group-justified .btn-group {
            float: none;
            display: table-cell;
            width: 1%; }
            .btn-group-justified .btn .btn,
            .btn-group-justified .btn-group .btn {
            width: 100%; }
            .btn-group-justified .btn .dropdown-menu,
            .btn-group-justified .btn-group .dropdown-menu {
            left: auto; }


            HTML



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <a class="btn btn-primary" href="#" role="button">Left</a>
            <a class="btn btn-primary" href="#" role="button">Middle</a>
            <a class="btn btn-primary" href="#" role="button">Right</a>
            </div>


            The above HTML code now will look like that shown in the figure beneath:



            enter image description here



            Handling borders




            • Due to the specific HTML and CSS used to justify buttons (namely display: table-cell), the borders between them are doubled. In regular button groups, margin-left: -1px is used to stack the borders instead of removing them. However, margin doesn't work with display: table-cell. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.


            Links acting as buttons




            • If the <a> elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button".


            Dropdowns



            Use the following HTML code for dropdown buttons:



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group with nested dropdown">
            <a class="btn btn-secondary" href="#" role="button">Left</a>
            <a class="btn btn-secondary" href="#" role="button">Middle</a>
            <div class="btn-group">
            <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Action
            </button>
            <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
            </div>
            </div>
            </div>


            The justified button group with dropdown button should look like that shown in the figure below:



            enter image description here



            With <button> elements




            • To use justified button groups with <button> elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to <button> elements, but since we support button dropdowns, we can work around that.


            HTML



             <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Left</button>
            </div>
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Middle</button>
            </div>
            <div class="btn-group" role="group">
            <button type="button" class="btn btn-secondary">Right</button>
            </div>
            </div>


            The above HTML code used to justified button groups with <button> elements should look like that shown in the figure beneath:



            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 24 '15 at 9:39









            Bass JobsenBass Jobsen

            44k14126209




            44k14126209













            • why set the width of the btn to 1% within the btn-group? Is this intended?

              – luQ
              Oct 18 '17 at 12:54





















            • why set the width of the btn to 1% within the btn-group? Is this intended?

              – luQ
              Oct 18 '17 at 12:54



















            why set the width of the btn to 1% within the btn-group? Is this intended?

            – luQ
            Oct 18 '17 at 12:54







            why set the width of the btn to 1% within the btn-group? Is this intended?

            – luQ
            Oct 18 '17 at 12:54













            20














            Building on Bass Jobsen's great answer, here is the same functionality using flexbox instead of display: table;



            SCSS code



            // Justified button groups
            // ----------------------

            .btn-group-justified {
            display: flex;
            width: 100%;
            .btn,
            .btn-group {
            flex: 1;
            .btn {
            width: 100%;
            }
            .dropdown-menu {
            left: auto;
            }
            }
            }


            HTML



            <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <a class="btn btn-primary" href="#" role="button">Left</a>
            <a class="btn btn-primary" href="#" role="button">Middle</a>
            <a class="btn btn-primary" href="#" role="button">Right</a>
            </div>


            Please refer to Bass Jobsen's answer for more details on usage with dropdowns, HTML Links and more.






            share|improve this answer


























            • Excellent, it also avoids the double-border issue

              – Giuseppe
              Aug 25 '16 at 7:55











            • Suggestion: add & + & {margin-top: $btn-block-spacing-y;} to space out stacked justified button groups

              – Chris Barr
              Nov 28 '16 at 0:32


















            20














            Building on Bass Jobsen's great answer, here is the same functionality using flexbox instead of display: table;



            SCSS code



            // Justified button groups
            // ----------------------

            .btn-group-justified {
            display: flex;
            width: 100%;
            .btn,
            .btn-group {
            flex: 1;
            .btn {
            width: 100%;
            }
            .dropdown-menu {
            left: auto;
            }
            }
            }


            HTML



            <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <a class="btn btn-primary" href="#" role="button">Left</a>
            <a class="btn btn-primary" href="#" role="button">Middle</a>
            <a class="btn btn-primary" href="#" role="button">Right</a>
            </div>


            Please refer to Bass Jobsen's answer for more details on usage with dropdowns, HTML Links and more.






            share|improve this answer


























            • Excellent, it also avoids the double-border issue

              – Giuseppe
              Aug 25 '16 at 7:55











            • Suggestion: add & + & {margin-top: $btn-block-spacing-y;} to space out stacked justified button groups

              – Chris Barr
              Nov 28 '16 at 0:32
















            20












            20








            20







            Building on Bass Jobsen's great answer, here is the same functionality using flexbox instead of display: table;



            SCSS code



            // Justified button groups
            // ----------------------

            .btn-group-justified {
            display: flex;
            width: 100%;
            .btn,
            .btn-group {
            flex: 1;
            .btn {
            width: 100%;
            }
            .dropdown-menu {
            left: auto;
            }
            }
            }


            HTML



            <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <a class="btn btn-primary" href="#" role="button">Left</a>
            <a class="btn btn-primary" href="#" role="button">Middle</a>
            <a class="btn btn-primary" href="#" role="button">Right</a>
            </div>


            Please refer to Bass Jobsen's answer for more details on usage with dropdowns, HTML Links and more.






            share|improve this answer















            Building on Bass Jobsen's great answer, here is the same functionality using flexbox instead of display: table;



            SCSS code



            // Justified button groups
            // ----------------------

            .btn-group-justified {
            display: flex;
            width: 100%;
            .btn,
            .btn-group {
            flex: 1;
            .btn {
            width: 100%;
            }
            .dropdown-menu {
            left: auto;
            }
            }
            }


            HTML



            <div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
            <a class="btn btn-primary" href="#" role="button">Left</a>
            <a class="btn btn-primary" href="#" role="button">Middle</a>
            <a class="btn btn-primary" href="#" role="button">Right</a>
            </div>


            Please refer to Bass Jobsen's answer for more details on usage with dropdowns, HTML Links and more.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 23 '17 at 10:31









            Community

            11




            11










            answered Aug 24 '16 at 9:09









            Philip StanislausPhilip Stanislaus

            30124




            30124













            • Excellent, it also avoids the double-border issue

              – Giuseppe
              Aug 25 '16 at 7:55











            • Suggestion: add & + & {margin-top: $btn-block-spacing-y;} to space out stacked justified button groups

              – Chris Barr
              Nov 28 '16 at 0:32





















            • Excellent, it also avoids the double-border issue

              – Giuseppe
              Aug 25 '16 at 7:55











            • Suggestion: add & + & {margin-top: $btn-block-spacing-y;} to space out stacked justified button groups

              – Chris Barr
              Nov 28 '16 at 0:32



















            Excellent, it also avoids the double-border issue

            – Giuseppe
            Aug 25 '16 at 7:55





            Excellent, it also avoids the double-border issue

            – Giuseppe
            Aug 25 '16 at 7:55













            Suggestion: add & + & {margin-top: $btn-block-spacing-y;} to space out stacked justified button groups

            – Chris Barr
            Nov 28 '16 at 0:32







            Suggestion: add & + & {margin-top: $btn-block-spacing-y;} to space out stacked justified button groups

            – Chris Barr
            Nov 28 '16 at 0:32













            0














            When using with class="dropdown-menu" with Bootstrap V4.0, based on Chris Baswell' solution above and Bootstrap Documentation: https://getbootstrap.com/docs/4.0/components/button-group/#nesting



            <div class="btn-group d-flex" role="group">
            <button type="button" class="btn btn-secondary">1</button>
            <button type="button" class="btn btn-secondary">2</button>
            <div class="btn-group w-100" role="group">
            <button type="button" class="btn btn-secondary dropdown-toggle-no-carret w-100" title="MANAGE ENTRIES" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Drop Down
            </button>
            <div class="dropdown-menu">
            <a href="" class="btn btn-secondary w-100">Previous</a>
            <a href="" class="btn btn-secondary w-100">Next</a>
            </div>
            </div>
            </div>





            share|improve this answer






























              0














              When using with class="dropdown-menu" with Bootstrap V4.0, based on Chris Baswell' solution above and Bootstrap Documentation: https://getbootstrap.com/docs/4.0/components/button-group/#nesting



              <div class="btn-group d-flex" role="group">
              <button type="button" class="btn btn-secondary">1</button>
              <button type="button" class="btn btn-secondary">2</button>
              <div class="btn-group w-100" role="group">
              <button type="button" class="btn btn-secondary dropdown-toggle-no-carret w-100" title="MANAGE ENTRIES" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Drop Down
              </button>
              <div class="dropdown-menu">
              <a href="" class="btn btn-secondary w-100">Previous</a>
              <a href="" class="btn btn-secondary w-100">Next</a>
              </div>
              </div>
              </div>





              share|improve this answer




























                0












                0








                0







                When using with class="dropdown-menu" with Bootstrap V4.0, based on Chris Baswell' solution above and Bootstrap Documentation: https://getbootstrap.com/docs/4.0/components/button-group/#nesting



                <div class="btn-group d-flex" role="group">
                <button type="button" class="btn btn-secondary">1</button>
                <button type="button" class="btn btn-secondary">2</button>
                <div class="btn-group w-100" role="group">
                <button type="button" class="btn btn-secondary dropdown-toggle-no-carret w-100" title="MANAGE ENTRIES" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Drop Down
                </button>
                <div class="dropdown-menu">
                <a href="" class="btn btn-secondary w-100">Previous</a>
                <a href="" class="btn btn-secondary w-100">Next</a>
                </div>
                </div>
                </div>





                share|improve this answer















                When using with class="dropdown-menu" with Bootstrap V4.0, based on Chris Baswell' solution above and Bootstrap Documentation: https://getbootstrap.com/docs/4.0/components/button-group/#nesting



                <div class="btn-group d-flex" role="group">
                <button type="button" class="btn btn-secondary">1</button>
                <button type="button" class="btn btn-secondary">2</button>
                <div class="btn-group w-100" role="group">
                <button type="button" class="btn btn-secondary dropdown-toggle-no-carret w-100" title="MANAGE ENTRIES" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Drop Down
                </button>
                <div class="dropdown-menu">
                <a href="" class="btn btn-secondary w-100">Previous</a>
                <a href="" class="btn btn-secondary w-100">Next</a>
                </div>
                </div>
                </div>






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 4 at 17:20









                Lonely Neuron

                3,06831835




                3,06831835










                answered Mar 7 '18 at 15:47









                KingofDendroarKingofDendroar

                456




                456






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34450586%2fjustify-buttons-with-bootstrap-v4%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas