Bootstrap 4 add more sizes spacing











up vote
1
down vote

favorite












I'm in the middle of a web project, where spaces between sections have 80px.
I would like to create one more option in the bootstrap spacers.



For the moment I have in the sass code:



section {
padding: 0 80px;
}


Bootstrap spacers range from .25em to 3em (.p-5 = 40px)



I would like to create a .p-6 class containing 5em (80px)



The ideal would be:



<section class="py-5 py-md-6">


A bootstrap I have linked via CDN. I can not imagine how to create this with variables, somehow integrating it into the boostrap css. Could you give me any clues?










share|improve this question






















  • mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5). would this be compatible with other styled applied(bg, border, ...)?
    – G-Cyr
    Sep 8 '17 at 15:09

















up vote
1
down vote

favorite












I'm in the middle of a web project, where spaces between sections have 80px.
I would like to create one more option in the bootstrap spacers.



For the moment I have in the sass code:



section {
padding: 0 80px;
}


Bootstrap spacers range from .25em to 3em (.p-5 = 40px)



I would like to create a .p-6 class containing 5em (80px)



The ideal would be:



<section class="py-5 py-md-6">


A bootstrap I have linked via CDN. I can not imagine how to create this with variables, somehow integrating it into the boostrap css. Could you give me any clues?










share|improve this question






















  • mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5). would this be compatible with other styled applied(bg, border, ...)?
    – G-Cyr
    Sep 8 '17 at 15:09















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm in the middle of a web project, where spaces between sections have 80px.
I would like to create one more option in the bootstrap spacers.



For the moment I have in the sass code:



section {
padding: 0 80px;
}


Bootstrap spacers range from .25em to 3em (.p-5 = 40px)



I would like to create a .p-6 class containing 5em (80px)



The ideal would be:



<section class="py-5 py-md-6">


A bootstrap I have linked via CDN. I can not imagine how to create this with variables, somehow integrating it into the boostrap css. Could you give me any clues?










share|improve this question













I'm in the middle of a web project, where spaces between sections have 80px.
I would like to create one more option in the bootstrap spacers.



For the moment I have in the sass code:



section {
padding: 0 80px;
}


Bootstrap spacers range from .25em to 3em (.p-5 = 40px)



I would like to create a .p-6 class containing 5em (80px)



The ideal would be:



<section class="py-5 py-md-6">


A bootstrap I have linked via CDN. I can not imagine how to create this with variables, somehow integrating it into the boostrap css. Could you give me any clues?







css twitter-bootstrap sass spacing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 8 '17 at 14:59









nicogaldo

185218




185218












  • mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5). would this be compatible with other styled applied(bg, border, ...)?
    – G-Cyr
    Sep 8 '17 at 15:09




















  • mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5). would this be compatible with other styled applied(bg, border, ...)?
    – G-Cyr
    Sep 8 '17 at 15:09


















mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5). would this be compatible with other styled applied(bg, border, ...)?
– G-Cyr
Sep 8 '17 at 15:09






mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5). would this be compatible with other styled applied(bg, border, ...)?
– G-Cyr
Sep 8 '17 at 15:09














2 Answers
2






active

oldest

votes

















up vote
4
down vote













If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like



$spacers: (
0: 0,
1: ($spacer * .25),
2: ($spacer * .5),
3: $spacer,
4: ($spacer * 1.5),
5: ($spacer * 3),
6: ($spacer * 5)
)


The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100



Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):



.pt-6,
.py-6 {
padding-top: 5rem !important;
}

.pr-6,
.px-6 {
padding-right: 5rem !important;
}

.pb-6,
.py-6 {
padding-bottom: 5rem !important;
}

.pl-6,
.px-6 {
padding-left: 5rem !important;
}


and if you in particular want the medium breakpoint ones, you could do



@media (min-width: 768px) {
.pt-md-6,
.py-md-6 {
padding-top: 5rem !important;
}

.pr-md-6,
.px-md-6 {
padding-right: 5rem !important;
}

.pb-md-6,
.py-md-6 {
padding-bottom: 5rem !important;
}

.pl-md-6,
.px-md-6 {
padding-left: 5rem !important;
}
}





share|improve this answer




























    up vote
    0
    down vote













    If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)



     $spacer: 1rem !default;
    $spacers: () !default;
    // stylelint-disable-next-line scss/dollar-variable-default
    $spacers: map-merge(
    (
    0: 0,
    1: ($spacer * .25), //4px
    2: ($spacer * .5), //8px
    3: $spacer, //16px
    4: ($spacer * 1.5), //24px
    5: ($spacer * 3), //48px
    6: ($spacer * 4), //64px
    7: ($spacer * 5), //80px
    8: ($spacer * 6.25), //100px
    9: ($spacer * 7.5), //120px
    10: ($spacer * 9.375) //150px
    ),
    $spacers





    share|improve this answer





















    • This code is just a copy-paste from Bootstrap's _variables.scss. What is the official way of completely replacining the $spacers entries? Like when you need to add a .125 multiplier to be the first item with shifting all the others.
      – Alexander Abakumov
      Nov 14 at 22:08












    • Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
      – Stavros
      9 hours ago










    • Alright :) I've meant that when using this snippet we probably would not want to copy those !defaults. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
      – Alexander Abakumov
      8 hours ago











    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',
    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%2f46119384%2fbootstrap-4-add-more-sizes-spacing%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote













    If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like



    $spacers: (
    0: 0,
    1: ($spacer * .25),
    2: ($spacer * .5),
    3: $spacer,
    4: ($spacer * 1.5),
    5: ($spacer * 3),
    6: ($spacer * 5)
    )


    The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100



    Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):



    .pt-6,
    .py-6 {
    padding-top: 5rem !important;
    }

    .pr-6,
    .px-6 {
    padding-right: 5rem !important;
    }

    .pb-6,
    .py-6 {
    padding-bottom: 5rem !important;
    }

    .pl-6,
    .px-6 {
    padding-left: 5rem !important;
    }


    and if you in particular want the medium breakpoint ones, you could do



    @media (min-width: 768px) {
    .pt-md-6,
    .py-md-6 {
    padding-top: 5rem !important;
    }

    .pr-md-6,
    .px-md-6 {
    padding-right: 5rem !important;
    }

    .pb-md-6,
    .py-md-6 {
    padding-bottom: 5rem !important;
    }

    .pl-md-6,
    .px-md-6 {
    padding-left: 5rem !important;
    }
    }





    share|improve this answer

























      up vote
      4
      down vote













      If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like



      $spacers: (
      0: 0,
      1: ($spacer * .25),
      2: ($spacer * .5),
      3: $spacer,
      4: ($spacer * 1.5),
      5: ($spacer * 3),
      6: ($spacer * 5)
      )


      The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100



      Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):



      .pt-6,
      .py-6 {
      padding-top: 5rem !important;
      }

      .pr-6,
      .px-6 {
      padding-right: 5rem !important;
      }

      .pb-6,
      .py-6 {
      padding-bottom: 5rem !important;
      }

      .pl-6,
      .px-6 {
      padding-left: 5rem !important;
      }


      and if you in particular want the medium breakpoint ones, you could do



      @media (min-width: 768px) {
      .pt-md-6,
      .py-md-6 {
      padding-top: 5rem !important;
      }

      .pr-md-6,
      .px-md-6 {
      padding-right: 5rem !important;
      }

      .pb-md-6,
      .py-md-6 {
      padding-bottom: 5rem !important;
      }

      .pl-md-6,
      .px-md-6 {
      padding-left: 5rem !important;
      }
      }





      share|improve this answer























        up vote
        4
        down vote










        up vote
        4
        down vote









        If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like



        $spacers: (
        0: 0,
        1: ($spacer * .25),
        2: ($spacer * .5),
        3: $spacer,
        4: ($spacer * 1.5),
        5: ($spacer * 3),
        6: ($spacer * 5)
        )


        The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100



        Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):



        .pt-6,
        .py-6 {
        padding-top: 5rem !important;
        }

        .pr-6,
        .px-6 {
        padding-right: 5rem !important;
        }

        .pb-6,
        .py-6 {
        padding-bottom: 5rem !important;
        }

        .pl-6,
        .px-6 {
        padding-left: 5rem !important;
        }


        and if you in particular want the medium breakpoint ones, you could do



        @media (min-width: 768px) {
        .pt-md-6,
        .py-md-6 {
        padding-top: 5rem !important;
        }

        .pr-md-6,
        .px-md-6 {
        padding-right: 5rem !important;
        }

        .pb-md-6,
        .py-md-6 {
        padding-bottom: 5rem !important;
        }

        .pl-md-6,
        .px-md-6 {
        padding-left: 5rem !important;
        }
        }





        share|improve this answer












        If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like



        $spacers: (
        0: 0,
        1: ($spacer * .25),
        2: ($spacer * .5),
        3: $spacer,
        4: ($spacer * 1.5),
        5: ($spacer * 3),
        6: ($spacer * 5)
        )


        The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100



        Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):



        .pt-6,
        .py-6 {
        padding-top: 5rem !important;
        }

        .pr-6,
        .px-6 {
        padding-right: 5rem !important;
        }

        .pb-6,
        .py-6 {
        padding-bottom: 5rem !important;
        }

        .pl-6,
        .px-6 {
        padding-left: 5rem !important;
        }


        and if you in particular want the medium breakpoint ones, you could do



        @media (min-width: 768px) {
        .pt-md-6,
        .py-md-6 {
        padding-top: 5rem !important;
        }

        .pr-md-6,
        .px-md-6 {
        padding-right: 5rem !important;
        }

        .pb-md-6,
        .py-md-6 {
        padding-bottom: 5rem !important;
        }

        .pl-md-6,
        .px-md-6 {
        padding-left: 5rem !important;
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 8 '17 at 22:01









        kball

        66936




        66936
























            up vote
            0
            down vote













            If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)



             $spacer: 1rem !default;
            $spacers: () !default;
            // stylelint-disable-next-line scss/dollar-variable-default
            $spacers: map-merge(
            (
            0: 0,
            1: ($spacer * .25), //4px
            2: ($spacer * .5), //8px
            3: $spacer, //16px
            4: ($spacer * 1.5), //24px
            5: ($spacer * 3), //48px
            6: ($spacer * 4), //64px
            7: ($spacer * 5), //80px
            8: ($spacer * 6.25), //100px
            9: ($spacer * 7.5), //120px
            10: ($spacer * 9.375) //150px
            ),
            $spacers





            share|improve this answer





















            • This code is just a copy-paste from Bootstrap's _variables.scss. What is the official way of completely replacining the $spacers entries? Like when you need to add a .125 multiplier to be the first item with shifting all the others.
              – Alexander Abakumov
              Nov 14 at 22:08












            • Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
              – Stavros
              9 hours ago










            • Alright :) I've meant that when using this snippet we probably would not want to copy those !defaults. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
              – Alexander Abakumov
              8 hours ago















            up vote
            0
            down vote













            If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)



             $spacer: 1rem !default;
            $spacers: () !default;
            // stylelint-disable-next-line scss/dollar-variable-default
            $spacers: map-merge(
            (
            0: 0,
            1: ($spacer * .25), //4px
            2: ($spacer * .5), //8px
            3: $spacer, //16px
            4: ($spacer * 1.5), //24px
            5: ($spacer * 3), //48px
            6: ($spacer * 4), //64px
            7: ($spacer * 5), //80px
            8: ($spacer * 6.25), //100px
            9: ($spacer * 7.5), //120px
            10: ($spacer * 9.375) //150px
            ),
            $spacers





            share|improve this answer





















            • This code is just a copy-paste from Bootstrap's _variables.scss. What is the official way of completely replacining the $spacers entries? Like when you need to add a .125 multiplier to be the first item with shifting all the others.
              – Alexander Abakumov
              Nov 14 at 22:08












            • Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
              – Stavros
              9 hours ago










            • Alright :) I've meant that when using this snippet we probably would not want to copy those !defaults. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
              – Alexander Abakumov
              8 hours ago













            up vote
            0
            down vote










            up vote
            0
            down vote









            If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)



             $spacer: 1rem !default;
            $spacers: () !default;
            // stylelint-disable-next-line scss/dollar-variable-default
            $spacers: map-merge(
            (
            0: 0,
            1: ($spacer * .25), //4px
            2: ($spacer * .5), //8px
            3: $spacer, //16px
            4: ($spacer * 1.5), //24px
            5: ($spacer * 3), //48px
            6: ($spacer * 4), //64px
            7: ($spacer * 5), //80px
            8: ($spacer * 6.25), //100px
            9: ($spacer * 7.5), //120px
            10: ($spacer * 9.375) //150px
            ),
            $spacers





            share|improve this answer












            If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)



             $spacer: 1rem !default;
            $spacers: () !default;
            // stylelint-disable-next-line scss/dollar-variable-default
            $spacers: map-merge(
            (
            0: 0,
            1: ($spacer * .25), //4px
            2: ($spacer * .5), //8px
            3: $spacer, //16px
            4: ($spacer * 1.5), //24px
            5: ($spacer * 3), //48px
            6: ($spacer * 4), //64px
            7: ($spacer * 5), //80px
            8: ($spacer * 6.25), //100px
            9: ($spacer * 7.5), //120px
            10: ($spacer * 9.375) //150px
            ),
            $spacers






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 10 at 22:07









            Stavros

            32




            32












            • This code is just a copy-paste from Bootstrap's _variables.scss. What is the official way of completely replacining the $spacers entries? Like when you need to add a .125 multiplier to be the first item with shifting all the others.
              – Alexander Abakumov
              Nov 14 at 22:08












            • Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
              – Stavros
              9 hours ago










            • Alright :) I've meant that when using this snippet we probably would not want to copy those !defaults. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
              – Alexander Abakumov
              8 hours ago


















            • This code is just a copy-paste from Bootstrap's _variables.scss. What is the official way of completely replacining the $spacers entries? Like when you need to add a .125 multiplier to be the first item with shifting all the others.
              – Alexander Abakumov
              Nov 14 at 22:08












            • Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
              – Stavros
              9 hours ago










            • Alright :) I've meant that when using this snippet we probably would not want to copy those !defaults. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
              – Alexander Abakumov
              8 hours ago
















            This code is just a copy-paste from Bootstrap's _variables.scss. What is the official way of completely replacining the $spacers entries? Like when you need to add a .125 multiplier to be the first item with shifting all the others.
            – Alexander Abakumov
            Nov 14 at 22:08






            This code is just a copy-paste from Bootstrap's _variables.scss. What is the official way of completely replacining the $spacers entries? Like when you need to add a .125 multiplier to be the first item with shifting all the others.
            – Alexander Abakumov
            Nov 14 at 22:08














            Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
            – Stavros
            9 hours ago




            Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
            – Stavros
            9 hours ago












            Alright :) I've meant that when using this snippet we probably would not want to copy those !defaults. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
            – Alexander Abakumov
            8 hours ago




            Alright :) I've meant that when using this snippet we probably would not want to copy those !defaults. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
            – Alexander Abakumov
            8 hours ago


















             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46119384%2fbootstrap-4-add-more-sizes-spacing%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

            Bressuire

            Vorschmack

            Quarantine