Using media breakpoints in Bootstrap 4-alpha












31














In Bootstrap 3 I use this:



.something {
padding: 5px;
@media screen and (min-width: $screen-sm-min) {
padding: 20px;
}
@media screen and (min-width: $screen-md-min) {
padding: 40px;
}
}


How can I do the same thing in Boostrap 4-alpha? I can't find an example in their docs.
This is in variables.scss



$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
) !default;
@include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
@include _assert-starts-at-zero($grid-breakpoints);









share|improve this question



























    31














    In Bootstrap 3 I use this:



    .something {
    padding: 5px;
    @media screen and (min-width: $screen-sm-min) {
    padding: 20px;
    }
    @media screen and (min-width: $screen-md-min) {
    padding: 40px;
    }
    }


    How can I do the same thing in Boostrap 4-alpha? I can't find an example in their docs.
    This is in variables.scss



    $grid-breakpoints: (
    xs: 0,
    sm: 576px,
    md: 768px,
    lg: 992px,
    xl: 1200px
    ) !default;
    @include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
    @include _assert-starts-at-zero($grid-breakpoints);









    share|improve this question

























      31












      31








      31


      19





      In Bootstrap 3 I use this:



      .something {
      padding: 5px;
      @media screen and (min-width: $screen-sm-min) {
      padding: 20px;
      }
      @media screen and (min-width: $screen-md-min) {
      padding: 40px;
      }
      }


      How can I do the same thing in Boostrap 4-alpha? I can't find an example in their docs.
      This is in variables.scss



      $grid-breakpoints: (
      xs: 0,
      sm: 576px,
      md: 768px,
      lg: 992px,
      xl: 1200px
      ) !default;
      @include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
      @include _assert-starts-at-zero($grid-breakpoints);









      share|improve this question













      In Bootstrap 3 I use this:



      .something {
      padding: 5px;
      @media screen and (min-width: $screen-sm-min) {
      padding: 20px;
      }
      @media screen and (min-width: $screen-md-min) {
      padding: 40px;
      }
      }


      How can I do the same thing in Boostrap 4-alpha? I can't find an example in their docs.
      This is in variables.scss



      $grid-breakpoints: (
      xs: 0,
      sm: 576px,
      md: 768px,
      lg: 992px,
      xl: 1200px
      ) !default;
      @include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
      @include _assert-starts-at-zero($grid-breakpoints);






      twitter-bootstrap






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 17 '17 at 13:44









      Ivan TopićIvan Topić

      78731123




      78731123
























          2 Answers
          2






          active

          oldest

          votes


















          79














          Use breakpoint mixins like this:



          .something {
          padding: 5px;
          @include media-breakpoint-up(sm) {
          padding: 20px;
          }
          @include media-breakpoint-up(md) {
          padding: 40px;
          }
          }


          v4 breakpoints reference



          v4 alpha6 breakpoints reference





          Below full options and values.



          Breakpoint & up (toggle on value and above):



          @include media-breakpoint-up(xs) { ... }
          @include media-breakpoint-up(sm) { ... }
          @include media-breakpoint-up(md) { ... }
          @include media-breakpoint-up(lg) { ... }
          @include media-breakpoint-up(xl) { ... }


          breakpoint & up values:



          // Extra small devices (portrait phones, less than 576px)
          // No media query since this is the default in Bootstrap

          // Small devices (landscape phones, 576px and up)
          @media (min-width: 576px) { ... }

          // Medium devices (tablets, 768px and up)
          @media (min-width: 768px) { ... }

          // Large devices (desktops, 992px and up)
          @media (min-width: 992px) { ... }

          // Extra large devices (large desktops, 1200px and up)
          @media (min-width: 1200px) { ... }


          breakpoint & down (toggle on value and down):



          @include media-breakpoint-down(xs) { ... }
          @include media-breakpoint-down(sm) { ... }
          @include media-breakpoint-down(md) { ... }
          @include media-breakpoint-down(lg) { ... }


          breakpoint & down values:



          // Extra small devices (portrait phones, less than 576px)
          @media (max-width: 575px) { ... }

          // Small devices (landscape phones, less than 768px)
          @media (max-width: 767px) { ... }

          // Medium devices (tablets, less than 992px)
          @media (max-width: 991px) { ... }

          // Large devices (desktops, less than 1200px)
          @media (max-width: 1199px) { ... }

          // Extra large devices (large desktops)
          // No media query since the extra-large breakpoint has no upper bound on its width


          breakpoint only:



          @include media-breakpoint-only(xs) { ... }
          @include media-breakpoint-only(sm) { ... }
          @include media-breakpoint-only(md) { ... }
          @include media-breakpoint-only(lg) { ... }
          @include media-breakpoint-only(xl) { ... }


          breakpoint only values (toggle in between values only):



          // Extra small devices (portrait phones, less than 576px)
          @media (max-width: 575px) { ... }

          // Small devices (landscape phones, 576px and up)
          @media (min-width: 576px) and (max-width: 767px) { ... }

          // Medium devices (tablets, 768px and up)
          @media (min-width: 768px) and (max-width: 991px) { ... }

          // Large devices (desktops, 992px and up)
          @media (min-width: 992px) and (max-width: 1199px) { ... }

          // Extra large devices (large desktops, 1200px and up)
          @media (min-width: 1200px) { ... }





          share|improve this answer































            8














            I answered a similar question here



            As @Syden said, the mixins will work. Another option is using SASS map-get like this..



            @media (min-width: map-get($grid-breakpoints, sm)){
            .something {
            padding: 10px;
            }
            }

            @media (min-width: map-get($grid-breakpoints, md)){
            .something {
            padding: 20px;
            }
            }


            http://www.codeply.com/go/0TU586QNlV






            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%2f41698747%2fusing-media-breakpoints-in-bootstrap-4-alpha%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









              79














              Use breakpoint mixins like this:



              .something {
              padding: 5px;
              @include media-breakpoint-up(sm) {
              padding: 20px;
              }
              @include media-breakpoint-up(md) {
              padding: 40px;
              }
              }


              v4 breakpoints reference



              v4 alpha6 breakpoints reference





              Below full options and values.



              Breakpoint & up (toggle on value and above):



              @include media-breakpoint-up(xs) { ... }
              @include media-breakpoint-up(sm) { ... }
              @include media-breakpoint-up(md) { ... }
              @include media-breakpoint-up(lg) { ... }
              @include media-breakpoint-up(xl) { ... }


              breakpoint & up values:



              // Extra small devices (portrait phones, less than 576px)
              // No media query since this is the default in Bootstrap

              // Small devices (landscape phones, 576px and up)
              @media (min-width: 576px) { ... }

              // Medium devices (tablets, 768px and up)
              @media (min-width: 768px) { ... }

              // Large devices (desktops, 992px and up)
              @media (min-width: 992px) { ... }

              // Extra large devices (large desktops, 1200px and up)
              @media (min-width: 1200px) { ... }


              breakpoint & down (toggle on value and down):



              @include media-breakpoint-down(xs) { ... }
              @include media-breakpoint-down(sm) { ... }
              @include media-breakpoint-down(md) { ... }
              @include media-breakpoint-down(lg) { ... }


              breakpoint & down values:



              // Extra small devices (portrait phones, less than 576px)
              @media (max-width: 575px) { ... }

              // Small devices (landscape phones, less than 768px)
              @media (max-width: 767px) { ... }

              // Medium devices (tablets, less than 992px)
              @media (max-width: 991px) { ... }

              // Large devices (desktops, less than 1200px)
              @media (max-width: 1199px) { ... }

              // Extra large devices (large desktops)
              // No media query since the extra-large breakpoint has no upper bound on its width


              breakpoint only:



              @include media-breakpoint-only(xs) { ... }
              @include media-breakpoint-only(sm) { ... }
              @include media-breakpoint-only(md) { ... }
              @include media-breakpoint-only(lg) { ... }
              @include media-breakpoint-only(xl) { ... }


              breakpoint only values (toggle in between values only):



              // Extra small devices (portrait phones, less than 576px)
              @media (max-width: 575px) { ... }

              // Small devices (landscape phones, 576px and up)
              @media (min-width: 576px) and (max-width: 767px) { ... }

              // Medium devices (tablets, 768px and up)
              @media (min-width: 768px) and (max-width: 991px) { ... }

              // Large devices (desktops, 992px and up)
              @media (min-width: 992px) and (max-width: 1199px) { ... }

              // Extra large devices (large desktops, 1200px and up)
              @media (min-width: 1200px) { ... }





              share|improve this answer




























                79














                Use breakpoint mixins like this:



                .something {
                padding: 5px;
                @include media-breakpoint-up(sm) {
                padding: 20px;
                }
                @include media-breakpoint-up(md) {
                padding: 40px;
                }
                }


                v4 breakpoints reference



                v4 alpha6 breakpoints reference





                Below full options and values.



                Breakpoint & up (toggle on value and above):



                @include media-breakpoint-up(xs) { ... }
                @include media-breakpoint-up(sm) { ... }
                @include media-breakpoint-up(md) { ... }
                @include media-breakpoint-up(lg) { ... }
                @include media-breakpoint-up(xl) { ... }


                breakpoint & up values:



                // Extra small devices (portrait phones, less than 576px)
                // No media query since this is the default in Bootstrap

                // Small devices (landscape phones, 576px and up)
                @media (min-width: 576px) { ... }

                // Medium devices (tablets, 768px and up)
                @media (min-width: 768px) { ... }

                // Large devices (desktops, 992px and up)
                @media (min-width: 992px) { ... }

                // Extra large devices (large desktops, 1200px and up)
                @media (min-width: 1200px) { ... }


                breakpoint & down (toggle on value and down):



                @include media-breakpoint-down(xs) { ... }
                @include media-breakpoint-down(sm) { ... }
                @include media-breakpoint-down(md) { ... }
                @include media-breakpoint-down(lg) { ... }


                breakpoint & down values:



                // Extra small devices (portrait phones, less than 576px)
                @media (max-width: 575px) { ... }

                // Small devices (landscape phones, less than 768px)
                @media (max-width: 767px) { ... }

                // Medium devices (tablets, less than 992px)
                @media (max-width: 991px) { ... }

                // Large devices (desktops, less than 1200px)
                @media (max-width: 1199px) { ... }

                // Extra large devices (large desktops)
                // No media query since the extra-large breakpoint has no upper bound on its width


                breakpoint only:



                @include media-breakpoint-only(xs) { ... }
                @include media-breakpoint-only(sm) { ... }
                @include media-breakpoint-only(md) { ... }
                @include media-breakpoint-only(lg) { ... }
                @include media-breakpoint-only(xl) { ... }


                breakpoint only values (toggle in between values only):



                // Extra small devices (portrait phones, less than 576px)
                @media (max-width: 575px) { ... }

                // Small devices (landscape phones, 576px and up)
                @media (min-width: 576px) and (max-width: 767px) { ... }

                // Medium devices (tablets, 768px and up)
                @media (min-width: 768px) and (max-width: 991px) { ... }

                // Large devices (desktops, 992px and up)
                @media (min-width: 992px) and (max-width: 1199px) { ... }

                // Extra large devices (large desktops, 1200px and up)
                @media (min-width: 1200px) { ... }





                share|improve this answer


























                  79












                  79








                  79






                  Use breakpoint mixins like this:



                  .something {
                  padding: 5px;
                  @include media-breakpoint-up(sm) {
                  padding: 20px;
                  }
                  @include media-breakpoint-up(md) {
                  padding: 40px;
                  }
                  }


                  v4 breakpoints reference



                  v4 alpha6 breakpoints reference





                  Below full options and values.



                  Breakpoint & up (toggle on value and above):



                  @include media-breakpoint-up(xs) { ... }
                  @include media-breakpoint-up(sm) { ... }
                  @include media-breakpoint-up(md) { ... }
                  @include media-breakpoint-up(lg) { ... }
                  @include media-breakpoint-up(xl) { ... }


                  breakpoint & up values:



                  // Extra small devices (portrait phones, less than 576px)
                  // No media query since this is the default in Bootstrap

                  // Small devices (landscape phones, 576px and up)
                  @media (min-width: 576px) { ... }

                  // Medium devices (tablets, 768px and up)
                  @media (min-width: 768px) { ... }

                  // Large devices (desktops, 992px and up)
                  @media (min-width: 992px) { ... }

                  // Extra large devices (large desktops, 1200px and up)
                  @media (min-width: 1200px) { ... }


                  breakpoint & down (toggle on value and down):



                  @include media-breakpoint-down(xs) { ... }
                  @include media-breakpoint-down(sm) { ... }
                  @include media-breakpoint-down(md) { ... }
                  @include media-breakpoint-down(lg) { ... }


                  breakpoint & down values:



                  // Extra small devices (portrait phones, less than 576px)
                  @media (max-width: 575px) { ... }

                  // Small devices (landscape phones, less than 768px)
                  @media (max-width: 767px) { ... }

                  // Medium devices (tablets, less than 992px)
                  @media (max-width: 991px) { ... }

                  // Large devices (desktops, less than 1200px)
                  @media (max-width: 1199px) { ... }

                  // Extra large devices (large desktops)
                  // No media query since the extra-large breakpoint has no upper bound on its width


                  breakpoint only:



                  @include media-breakpoint-only(xs) { ... }
                  @include media-breakpoint-only(sm) { ... }
                  @include media-breakpoint-only(md) { ... }
                  @include media-breakpoint-only(lg) { ... }
                  @include media-breakpoint-only(xl) { ... }


                  breakpoint only values (toggle in between values only):



                  // Extra small devices (portrait phones, less than 576px)
                  @media (max-width: 575px) { ... }

                  // Small devices (landscape phones, 576px and up)
                  @media (min-width: 576px) and (max-width: 767px) { ... }

                  // Medium devices (tablets, 768px and up)
                  @media (min-width: 768px) and (max-width: 991px) { ... }

                  // Large devices (desktops, 992px and up)
                  @media (min-width: 992px) and (max-width: 1199px) { ... }

                  // Extra large devices (large desktops, 1200px and up)
                  @media (min-width: 1200px) { ... }





                  share|improve this answer














                  Use breakpoint mixins like this:



                  .something {
                  padding: 5px;
                  @include media-breakpoint-up(sm) {
                  padding: 20px;
                  }
                  @include media-breakpoint-up(md) {
                  padding: 40px;
                  }
                  }


                  v4 breakpoints reference



                  v4 alpha6 breakpoints reference





                  Below full options and values.



                  Breakpoint & up (toggle on value and above):



                  @include media-breakpoint-up(xs) { ... }
                  @include media-breakpoint-up(sm) { ... }
                  @include media-breakpoint-up(md) { ... }
                  @include media-breakpoint-up(lg) { ... }
                  @include media-breakpoint-up(xl) { ... }


                  breakpoint & up values:



                  // Extra small devices (portrait phones, less than 576px)
                  // No media query since this is the default in Bootstrap

                  // Small devices (landscape phones, 576px and up)
                  @media (min-width: 576px) { ... }

                  // Medium devices (tablets, 768px and up)
                  @media (min-width: 768px) { ... }

                  // Large devices (desktops, 992px and up)
                  @media (min-width: 992px) { ... }

                  // Extra large devices (large desktops, 1200px and up)
                  @media (min-width: 1200px) { ... }


                  breakpoint & down (toggle on value and down):



                  @include media-breakpoint-down(xs) { ... }
                  @include media-breakpoint-down(sm) { ... }
                  @include media-breakpoint-down(md) { ... }
                  @include media-breakpoint-down(lg) { ... }


                  breakpoint & down values:



                  // Extra small devices (portrait phones, less than 576px)
                  @media (max-width: 575px) { ... }

                  // Small devices (landscape phones, less than 768px)
                  @media (max-width: 767px) { ... }

                  // Medium devices (tablets, less than 992px)
                  @media (max-width: 991px) { ... }

                  // Large devices (desktops, less than 1200px)
                  @media (max-width: 1199px) { ... }

                  // Extra large devices (large desktops)
                  // No media query since the extra-large breakpoint has no upper bound on its width


                  breakpoint only:



                  @include media-breakpoint-only(xs) { ... }
                  @include media-breakpoint-only(sm) { ... }
                  @include media-breakpoint-only(md) { ... }
                  @include media-breakpoint-only(lg) { ... }
                  @include media-breakpoint-only(xl) { ... }


                  breakpoint only values (toggle in between values only):



                  // Extra small devices (portrait phones, less than 576px)
                  @media (max-width: 575px) { ... }

                  // Small devices (landscape phones, 576px and up)
                  @media (min-width: 576px) and (max-width: 767px) { ... }

                  // Medium devices (tablets, 768px and up)
                  @media (min-width: 768px) and (max-width: 991px) { ... }

                  // Large devices (desktops, 992px and up)
                  @media (min-width: 992px) and (max-width: 1199px) { ... }

                  // Extra large devices (large desktops, 1200px and up)
                  @media (min-width: 1200px) { ... }






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 26 '18 at 23:34

























                  answered Jan 17 '17 at 13:57









                  SydenSyden

                  6,47741632




                  6,47741632

























                      8














                      I answered a similar question here



                      As @Syden said, the mixins will work. Another option is using SASS map-get like this..



                      @media (min-width: map-get($grid-breakpoints, sm)){
                      .something {
                      padding: 10px;
                      }
                      }

                      @media (min-width: map-get($grid-breakpoints, md)){
                      .something {
                      padding: 20px;
                      }
                      }


                      http://www.codeply.com/go/0TU586QNlV






                      share|improve this answer




























                        8














                        I answered a similar question here



                        As @Syden said, the mixins will work. Another option is using SASS map-get like this..



                        @media (min-width: map-get($grid-breakpoints, sm)){
                        .something {
                        padding: 10px;
                        }
                        }

                        @media (min-width: map-get($grid-breakpoints, md)){
                        .something {
                        padding: 20px;
                        }
                        }


                        http://www.codeply.com/go/0TU586QNlV






                        share|improve this answer


























                          8












                          8








                          8






                          I answered a similar question here



                          As @Syden said, the mixins will work. Another option is using SASS map-get like this..



                          @media (min-width: map-get($grid-breakpoints, sm)){
                          .something {
                          padding: 10px;
                          }
                          }

                          @media (min-width: map-get($grid-breakpoints, md)){
                          .something {
                          padding: 20px;
                          }
                          }


                          http://www.codeply.com/go/0TU586QNlV






                          share|improve this answer














                          I answered a similar question here



                          As @Syden said, the mixins will work. Another option is using SASS map-get like this..



                          @media (min-width: map-get($grid-breakpoints, sm)){
                          .something {
                          padding: 10px;
                          }
                          }

                          @media (min-width: map-get($grid-breakpoints, md)){
                          .something {
                          padding: 20px;
                          }
                          }


                          http://www.codeply.com/go/0TU586QNlV







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited May 23 '17 at 12:02









                          Community

                          11




                          11










                          answered Jan 17 '17 at 14:05









                          ZimZim

                          184k47383371




                          184k47383371






























                              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.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • 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%2f41698747%2fusing-media-breakpoints-in-bootstrap-4-alpha%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

                              Paul Cézanne

                              UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

                              Angular material date-picker (MatDatepicker) auto completes the date on focus out