Bootstrap. How to add bottom margin for mobile screen only?












2















I have this HTML code



<div class="row">
<div class="col-xs-12">
<div class="titulo">
<h2 class="title-section font-switch">Algunos tecnologias que manejamos</h2>
<span>Si no vez el que necesitas pregunta, a veces no ponemos todos</span>
</div>


</div>
<div class="col-xs-12 col-sm-8 col-sm-offset-2">
<div class="row center">
<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/csharp.png" class="img-responsive" alt="">
</a>
</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">


<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/java.jpg" class="img-responsive" alt="">
</a>
</div>

<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/cmasmas.png" class="img-responsive" alt="">
</a>

</div>

<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/androidstudio.png" class="img-responsive" alt="">
</a>



</div>



</div>
</div>


</div>


this is displayed as it:



enter image description here



but when screen size is changed to mobile screen the view is it:



a margin is needed (top or bottom or both)
enter image description here



I know I could add it with Media queries, but I believe if I am using bootstrap I must to use less posible the media queries.



How can I add a margin only for mobile screen?










share|improve this question























  • Bootstrap's media queries. That tutorial goes through bootstrap's own break points. No reason you couldn't add one of those media queries to your own css.

    – Brian
    Jun 8 '16 at 18:25
















2















I have this HTML code



<div class="row">
<div class="col-xs-12">
<div class="titulo">
<h2 class="title-section font-switch">Algunos tecnologias que manejamos</h2>
<span>Si no vez el que necesitas pregunta, a veces no ponemos todos</span>
</div>


</div>
<div class="col-xs-12 col-sm-8 col-sm-offset-2">
<div class="row center">
<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/csharp.png" class="img-responsive" alt="">
</a>
</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">


<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/java.jpg" class="img-responsive" alt="">
</a>
</div>

<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/cmasmas.png" class="img-responsive" alt="">
</a>

</div>

<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/androidstudio.png" class="img-responsive" alt="">
</a>



</div>



</div>
</div>


</div>


this is displayed as it:



enter image description here



but when screen size is changed to mobile screen the view is it:



a margin is needed (top or bottom or both)
enter image description here



I know I could add it with Media queries, but I believe if I am using bootstrap I must to use less posible the media queries.



How can I add a margin only for mobile screen?










share|improve this question























  • Bootstrap's media queries. That tutorial goes through bootstrap's own break points. No reason you couldn't add one of those media queries to your own css.

    – Brian
    Jun 8 '16 at 18:25














2












2








2


1






I have this HTML code



<div class="row">
<div class="col-xs-12">
<div class="titulo">
<h2 class="title-section font-switch">Algunos tecnologias que manejamos</h2>
<span>Si no vez el que necesitas pregunta, a veces no ponemos todos</span>
</div>


</div>
<div class="col-xs-12 col-sm-8 col-sm-offset-2">
<div class="row center">
<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/csharp.png" class="img-responsive" alt="">
</a>
</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">


<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/java.jpg" class="img-responsive" alt="">
</a>
</div>

<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/cmasmas.png" class="img-responsive" alt="">
</a>

</div>

<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/androidstudio.png" class="img-responsive" alt="">
</a>



</div>



</div>
</div>


</div>


this is displayed as it:



enter image description here



but when screen size is changed to mobile screen the view is it:



a margin is needed (top or bottom or both)
enter image description here



I know I could add it with Media queries, but I believe if I am using bootstrap I must to use less posible the media queries.



How can I add a margin only for mobile screen?










share|improve this question














I have this HTML code



<div class="row">
<div class="col-xs-12">
<div class="titulo">
<h2 class="title-section font-switch">Algunos tecnologias que manejamos</h2>
<span>Si no vez el que necesitas pregunta, a veces no ponemos todos</span>
</div>


</div>
<div class="col-xs-12 col-sm-8 col-sm-offset-2">
<div class="row center">
<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/csharp.png" class="img-responsive" alt="">
</a>
</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">


<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/java.jpg" class="img-responsive" alt="">
</a>
</div>

<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/cmasmas.png" class="img-responsive" alt="">
</a>

</div>

<div class="col-xs-10 col-xs-offset-1 col-sm-3 col-sm-offset-0 vcenter">

<a href="#portfolioModal1" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img src="img/androidstudio.png" class="img-responsive" alt="">
</a>



</div>



</div>
</div>


</div>


this is displayed as it:



enter image description here



but when screen size is changed to mobile screen the view is it:



a margin is needed (top or bottom or both)
enter image description here



I know I could add it with Media queries, but I believe if I am using bootstrap I must to use less posible the media queries.



How can I add a margin only for mobile screen?







twitter-bootstrap twitter-bootstrap-3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 8 '16 at 18:20









angelangel

1,60464372




1,60464372













  • Bootstrap's media queries. That tutorial goes through bootstrap's own break points. No reason you couldn't add one of those media queries to your own css.

    – Brian
    Jun 8 '16 at 18:25



















  • Bootstrap's media queries. That tutorial goes through bootstrap's own break points. No reason you couldn't add one of those media queries to your own css.

    – Brian
    Jun 8 '16 at 18:25

















Bootstrap's media queries. That tutorial goes through bootstrap's own break points. No reason you couldn't add one of those media queries to your own css.

– Brian
Jun 8 '16 at 18:25





Bootstrap's media queries. That tutorial goes through bootstrap's own break points. No reason you couldn't add one of those media queries to your own css.

– Brian
Jun 8 '16 at 18:25












7 Answers
7






active

oldest

votes


















5














You can add div with .visible-xs which only display on xtra small screens and add your custom class margin, for example:



<div class="mobile-margin visible-xs"></div>


with custom css margins:



.mobile-margin { margin-top: 0px; }


and the margin will display only for xs screen.






share|improve this answer


























  • I hoped there was a built-in solution but this works for me. Thanks!

    – Rory
    Oct 7 '18 at 23:53



















3














I have this issue a lot so I created a custom class called "mobile-space" which I add to divs that need a margin-top only in mobile:



@media screen and (max-width: 767px) {
.mobile-space {margin-top:10px;}
}


Personally, I'd go this route WITH a media query rather than adding unnecessary html markup like divs.






share|improve this answer































    2














    Bootstrap 4 allows hidden-sm-up classes, which toggles one object from sm to xl.



    Then, you can add a column between each image column, and add this class that will be visible only in mobile devices.



    More info: https://v4-alpha.getbootstrap.com/layout/responsive-utilities/



    "Available classes"



    Sorry my english, :D






    share|improve this answer

































      1














      Simply apply a global style to all columns that have a dedicated mobile-column-size in the first place:



      # Add global bottom margins to mobile columns except full width
      @media all and (max-width: 767px) {
      .col-sm-1, .col-sm-2, .col-sm-3,
      .col-sm-4, .col-sm-5, .col-sm-6,
      .col-sm-7, .col-sm-8, .col-sm-9,
      .col-sm-10, .col-sm-11 {
      margin-bottom: 20px;
      }
      }


      If you need certain columns to have alternative margins, just add a dedicated class to those. This approach keeps the HTML clean in most cases.






      share|improve this answer































        0














        Here you go:



        @media (max-width: 480px) {
        .vcenter img {
        margin-bottom: 10px;
        }
        }


        Assuming vcenter is the common div wrapping those images.






        share|improve this answer































          0














          If you are using bootstrap 4 and you are consuming the sass-files (rather than just importing the bootstrap css) you can use this i wrote when I wanted to solve the same problem:



          $class-prefix-list: mt mb; //mr and ml can be added if needed
          $breakpoint-direction-list: up down;
          $breakpoint-list: xxs xs sm md lg xl;

          @mixin spacer-dynamic($breakpoint, $direction, $size, $breakpoint-direction) {
          @if($breakpoint-direction == 'up') {
          @include media-breakpoint-up($breakpoint) {
          @if $direction == 'mb' {
          margin-bottom: ($spacer/2) * ($size/2) !important;
          }

          @if $direction == 'mt' {
          margin-top: ($spacer/2) * ($size/2) !important;
          }

          @if $direction == 'mr' {
          margin-right: ($spacer/2) * ($size/2) !important;
          }

          @if $direction == 'ml' {
          margin-left: ($spacer/2) * ($size/2) !important;
          }
          }
          }

          @else if($breakpoint-direction == 'down') {
          @include media-breakpoint-down($breakpoint) {
          @if $direction == 'mb' {
          margin-bottom: ($spacer/2) * ($size/2) !important;
          }

          @if $direction == 'mt' {
          margin-top: ($spacer/2) * ($size/2) !important;
          }

          @if $direction == 'mr' {
          margin-right: ($spacer/2) * ($size/2) !important;
          }

          @if $direction == 'ml' {
          margin-left: ($spacer/2) * ($size/2) !important;
          }
          }
          }
          }

          @each $breakpoint in $breakpoint-list {
          @each $breakpoint-direction in $breakpoint-direction-list {
          @each $direction in $class-prefix-list {
          @for $i from 1 through 5 {
          .#{$direction}-#{$i}-#{$breakpoint}-#{$breakpoint-direction} {
          @include spacer-dynamic($breakpoint, $direction, $i, $breakpoint-direction);
          }
          }
          }
          }
          }


          It will generate a css with classes like this:



          @media (max-width: 1199px) {
          .mb-3-lg-down {
          margin-bottom: 1.125rem !important; } }

          @media (max-width: 1199px) {
          .mb-4-lg-down {
          margin-bottom: 1.5rem !important; } }





          share|improve this answer































            -1














            Bootstrap doesn't provide something for managing margins or paddings, but you could do something like this: jsFiddle link. Where you set the margin to a div with visible-xs class.



            <div class="container">
            <div class="row">
            <p>123123</p>
            <div class="xs-margin visible-xs">
            </div>
            <p>asdasdadasd</p>
            </div>
            </div>


            with css:



            .xs-margin {
            margin-bottom: 100px;
            }





            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%2f37710038%2fbootstrap-how-to-add-bottom-margin-for-mobile-screen-only%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              7 Answers
              7






              active

              oldest

              votes








              7 Answers
              7






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              5














              You can add div with .visible-xs which only display on xtra small screens and add your custom class margin, for example:



              <div class="mobile-margin visible-xs"></div>


              with custom css margins:



              .mobile-margin { margin-top: 0px; }


              and the margin will display only for xs screen.






              share|improve this answer


























              • I hoped there was a built-in solution but this works for me. Thanks!

                – Rory
                Oct 7 '18 at 23:53
















              5














              You can add div with .visible-xs which only display on xtra small screens and add your custom class margin, for example:



              <div class="mobile-margin visible-xs"></div>


              with custom css margins:



              .mobile-margin { margin-top: 0px; }


              and the margin will display only for xs screen.






              share|improve this answer


























              • I hoped there was a built-in solution but this works for me. Thanks!

                – Rory
                Oct 7 '18 at 23:53














              5












              5








              5







              You can add div with .visible-xs which only display on xtra small screens and add your custom class margin, for example:



              <div class="mobile-margin visible-xs"></div>


              with custom css margins:



              .mobile-margin { margin-top: 0px; }


              and the margin will display only for xs screen.






              share|improve this answer















              You can add div with .visible-xs which only display on xtra small screens and add your custom class margin, for example:



              <div class="mobile-margin visible-xs"></div>


              with custom css margins:



              .mobile-margin { margin-top: 0px; }


              and the margin will display only for xs screen.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 28 '18 at 16:27









              jaycer

              1,31911229




              1,31911229










              answered Jul 26 '18 at 14:39









              alvseekalvseek

              10318




              10318













              • I hoped there was a built-in solution but this works for me. Thanks!

                – Rory
                Oct 7 '18 at 23:53



















              • I hoped there was a built-in solution but this works for me. Thanks!

                – Rory
                Oct 7 '18 at 23:53

















              I hoped there was a built-in solution but this works for me. Thanks!

              – Rory
              Oct 7 '18 at 23:53





              I hoped there was a built-in solution but this works for me. Thanks!

              – Rory
              Oct 7 '18 at 23:53













              3














              I have this issue a lot so I created a custom class called "mobile-space" which I add to divs that need a margin-top only in mobile:



              @media screen and (max-width: 767px) {
              .mobile-space {margin-top:10px;}
              }


              Personally, I'd go this route WITH a media query rather than adding unnecessary html markup like divs.






              share|improve this answer




























                3














                I have this issue a lot so I created a custom class called "mobile-space" which I add to divs that need a margin-top only in mobile:



                @media screen and (max-width: 767px) {
                .mobile-space {margin-top:10px;}
                }


                Personally, I'd go this route WITH a media query rather than adding unnecessary html markup like divs.






                share|improve this answer


























                  3












                  3








                  3







                  I have this issue a lot so I created a custom class called "mobile-space" which I add to divs that need a margin-top only in mobile:



                  @media screen and (max-width: 767px) {
                  .mobile-space {margin-top:10px;}
                  }


                  Personally, I'd go this route WITH a media query rather than adding unnecessary html markup like divs.






                  share|improve this answer













                  I have this issue a lot so I created a custom class called "mobile-space" which I add to divs that need a margin-top only in mobile:



                  @media screen and (max-width: 767px) {
                  .mobile-space {margin-top:10px;}
                  }


                  Personally, I'd go this route WITH a media query rather than adding unnecessary html markup like divs.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jun 8 '16 at 19:55









                  Rachel SRachel S

                  2,34021026




                  2,34021026























                      2














                      Bootstrap 4 allows hidden-sm-up classes, which toggles one object from sm to xl.



                      Then, you can add a column between each image column, and add this class that will be visible only in mobile devices.



                      More info: https://v4-alpha.getbootstrap.com/layout/responsive-utilities/



                      "Available classes"



                      Sorry my english, :D






                      share|improve this answer






























                        2














                        Bootstrap 4 allows hidden-sm-up classes, which toggles one object from sm to xl.



                        Then, you can add a column between each image column, and add this class that will be visible only in mobile devices.



                        More info: https://v4-alpha.getbootstrap.com/layout/responsive-utilities/



                        "Available classes"



                        Sorry my english, :D






                        share|improve this answer




























                          2












                          2








                          2







                          Bootstrap 4 allows hidden-sm-up classes, which toggles one object from sm to xl.



                          Then, you can add a column between each image column, and add this class that will be visible only in mobile devices.



                          More info: https://v4-alpha.getbootstrap.com/layout/responsive-utilities/



                          "Available classes"



                          Sorry my english, :D






                          share|improve this answer















                          Bootstrap 4 allows hidden-sm-up classes, which toggles one object from sm to xl.



                          Then, you can add a column between each image column, and add this class that will be visible only in mobile devices.



                          More info: https://v4-alpha.getbootstrap.com/layout/responsive-utilities/



                          "Available classes"



                          Sorry my english, :D







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Feb 26 '18 at 16:51









                          Vladimir Samsonov

                          1,2112916




                          1,2112916










                          answered Feb 26 '18 at 13:50









                          Evaristo Canul LópezEvaristo Canul López

                          212




                          212























                              1














                              Simply apply a global style to all columns that have a dedicated mobile-column-size in the first place:



                              # Add global bottom margins to mobile columns except full width
                              @media all and (max-width: 767px) {
                              .col-sm-1, .col-sm-2, .col-sm-3,
                              .col-sm-4, .col-sm-5, .col-sm-6,
                              .col-sm-7, .col-sm-8, .col-sm-9,
                              .col-sm-10, .col-sm-11 {
                              margin-bottom: 20px;
                              }
                              }


                              If you need certain columns to have alternative margins, just add a dedicated class to those. This approach keeps the HTML clean in most cases.






                              share|improve this answer




























                                1














                                Simply apply a global style to all columns that have a dedicated mobile-column-size in the first place:



                                # Add global bottom margins to mobile columns except full width
                                @media all and (max-width: 767px) {
                                .col-sm-1, .col-sm-2, .col-sm-3,
                                .col-sm-4, .col-sm-5, .col-sm-6,
                                .col-sm-7, .col-sm-8, .col-sm-9,
                                .col-sm-10, .col-sm-11 {
                                margin-bottom: 20px;
                                }
                                }


                                If you need certain columns to have alternative margins, just add a dedicated class to those. This approach keeps the HTML clean in most cases.






                                share|improve this answer


























                                  1












                                  1








                                  1







                                  Simply apply a global style to all columns that have a dedicated mobile-column-size in the first place:



                                  # Add global bottom margins to mobile columns except full width
                                  @media all and (max-width: 767px) {
                                  .col-sm-1, .col-sm-2, .col-sm-3,
                                  .col-sm-4, .col-sm-5, .col-sm-6,
                                  .col-sm-7, .col-sm-8, .col-sm-9,
                                  .col-sm-10, .col-sm-11 {
                                  margin-bottom: 20px;
                                  }
                                  }


                                  If you need certain columns to have alternative margins, just add a dedicated class to those. This approach keeps the HTML clean in most cases.






                                  share|improve this answer













                                  Simply apply a global style to all columns that have a dedicated mobile-column-size in the first place:



                                  # Add global bottom margins to mobile columns except full width
                                  @media all and (max-width: 767px) {
                                  .col-sm-1, .col-sm-2, .col-sm-3,
                                  .col-sm-4, .col-sm-5, .col-sm-6,
                                  .col-sm-7, .col-sm-8, .col-sm-9,
                                  .col-sm-10, .col-sm-11 {
                                  margin-bottom: 20px;
                                  }
                                  }


                                  If you need certain columns to have alternative margins, just add a dedicated class to those. This approach keeps the HTML clean in most cases.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Nov 13 '18 at 14:23









                                  DavidDavid

                                  5391820




                                  5391820























                                      0














                                      Here you go:



                                      @media (max-width: 480px) {
                                      .vcenter img {
                                      margin-bottom: 10px;
                                      }
                                      }


                                      Assuming vcenter is the common div wrapping those images.






                                      share|improve this answer




























                                        0














                                        Here you go:



                                        @media (max-width: 480px) {
                                        .vcenter img {
                                        margin-bottom: 10px;
                                        }
                                        }


                                        Assuming vcenter is the common div wrapping those images.






                                        share|improve this answer


























                                          0












                                          0








                                          0







                                          Here you go:



                                          @media (max-width: 480px) {
                                          .vcenter img {
                                          margin-bottom: 10px;
                                          }
                                          }


                                          Assuming vcenter is the common div wrapping those images.






                                          share|improve this answer













                                          Here you go:



                                          @media (max-width: 480px) {
                                          .vcenter img {
                                          margin-bottom: 10px;
                                          }
                                          }


                                          Assuming vcenter is the common div wrapping those images.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Jun 8 '16 at 18:31









                                          AndrewL64AndrewL64

                                          8,76641642




                                          8,76641642























                                              0














                                              If you are using bootstrap 4 and you are consuming the sass-files (rather than just importing the bootstrap css) you can use this i wrote when I wanted to solve the same problem:



                                              $class-prefix-list: mt mb; //mr and ml can be added if needed
                                              $breakpoint-direction-list: up down;
                                              $breakpoint-list: xxs xs sm md lg xl;

                                              @mixin spacer-dynamic($breakpoint, $direction, $size, $breakpoint-direction) {
                                              @if($breakpoint-direction == 'up') {
                                              @include media-breakpoint-up($breakpoint) {
                                              @if $direction == 'mb' {
                                              margin-bottom: ($spacer/2) * ($size/2) !important;
                                              }

                                              @if $direction == 'mt' {
                                              margin-top: ($spacer/2) * ($size/2) !important;
                                              }

                                              @if $direction == 'mr' {
                                              margin-right: ($spacer/2) * ($size/2) !important;
                                              }

                                              @if $direction == 'ml' {
                                              margin-left: ($spacer/2) * ($size/2) !important;
                                              }
                                              }
                                              }

                                              @else if($breakpoint-direction == 'down') {
                                              @include media-breakpoint-down($breakpoint) {
                                              @if $direction == 'mb' {
                                              margin-bottom: ($spacer/2) * ($size/2) !important;
                                              }

                                              @if $direction == 'mt' {
                                              margin-top: ($spacer/2) * ($size/2) !important;
                                              }

                                              @if $direction == 'mr' {
                                              margin-right: ($spacer/2) * ($size/2) !important;
                                              }

                                              @if $direction == 'ml' {
                                              margin-left: ($spacer/2) * ($size/2) !important;
                                              }
                                              }
                                              }
                                              }

                                              @each $breakpoint in $breakpoint-list {
                                              @each $breakpoint-direction in $breakpoint-direction-list {
                                              @each $direction in $class-prefix-list {
                                              @for $i from 1 through 5 {
                                              .#{$direction}-#{$i}-#{$breakpoint}-#{$breakpoint-direction} {
                                              @include spacer-dynamic($breakpoint, $direction, $i, $breakpoint-direction);
                                              }
                                              }
                                              }
                                              }
                                              }


                                              It will generate a css with classes like this:



                                              @media (max-width: 1199px) {
                                              .mb-3-lg-down {
                                              margin-bottom: 1.125rem !important; } }

                                              @media (max-width: 1199px) {
                                              .mb-4-lg-down {
                                              margin-bottom: 1.5rem !important; } }





                                              share|improve this answer




























                                                0














                                                If you are using bootstrap 4 and you are consuming the sass-files (rather than just importing the bootstrap css) you can use this i wrote when I wanted to solve the same problem:



                                                $class-prefix-list: mt mb; //mr and ml can be added if needed
                                                $breakpoint-direction-list: up down;
                                                $breakpoint-list: xxs xs sm md lg xl;

                                                @mixin spacer-dynamic($breakpoint, $direction, $size, $breakpoint-direction) {
                                                @if($breakpoint-direction == 'up') {
                                                @include media-breakpoint-up($breakpoint) {
                                                @if $direction == 'mb' {
                                                margin-bottom: ($spacer/2) * ($size/2) !important;
                                                }

                                                @if $direction == 'mt' {
                                                margin-top: ($spacer/2) * ($size/2) !important;
                                                }

                                                @if $direction == 'mr' {
                                                margin-right: ($spacer/2) * ($size/2) !important;
                                                }

                                                @if $direction == 'ml' {
                                                margin-left: ($spacer/2) * ($size/2) !important;
                                                }
                                                }
                                                }

                                                @else if($breakpoint-direction == 'down') {
                                                @include media-breakpoint-down($breakpoint) {
                                                @if $direction == 'mb' {
                                                margin-bottom: ($spacer/2) * ($size/2) !important;
                                                }

                                                @if $direction == 'mt' {
                                                margin-top: ($spacer/2) * ($size/2) !important;
                                                }

                                                @if $direction == 'mr' {
                                                margin-right: ($spacer/2) * ($size/2) !important;
                                                }

                                                @if $direction == 'ml' {
                                                margin-left: ($spacer/2) * ($size/2) !important;
                                                }
                                                }
                                                }
                                                }

                                                @each $breakpoint in $breakpoint-list {
                                                @each $breakpoint-direction in $breakpoint-direction-list {
                                                @each $direction in $class-prefix-list {
                                                @for $i from 1 through 5 {
                                                .#{$direction}-#{$i}-#{$breakpoint}-#{$breakpoint-direction} {
                                                @include spacer-dynamic($breakpoint, $direction, $i, $breakpoint-direction);
                                                }
                                                }
                                                }
                                                }
                                                }


                                                It will generate a css with classes like this:



                                                @media (max-width: 1199px) {
                                                .mb-3-lg-down {
                                                margin-bottom: 1.125rem !important; } }

                                                @media (max-width: 1199px) {
                                                .mb-4-lg-down {
                                                margin-bottom: 1.5rem !important; } }





                                                share|improve this answer


























                                                  0












                                                  0








                                                  0







                                                  If you are using bootstrap 4 and you are consuming the sass-files (rather than just importing the bootstrap css) you can use this i wrote when I wanted to solve the same problem:



                                                  $class-prefix-list: mt mb; //mr and ml can be added if needed
                                                  $breakpoint-direction-list: up down;
                                                  $breakpoint-list: xxs xs sm md lg xl;

                                                  @mixin spacer-dynamic($breakpoint, $direction, $size, $breakpoint-direction) {
                                                  @if($breakpoint-direction == 'up') {
                                                  @include media-breakpoint-up($breakpoint) {
                                                  @if $direction == 'mb' {
                                                  margin-bottom: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'mt' {
                                                  margin-top: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'mr' {
                                                  margin-right: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'ml' {
                                                  margin-left: ($spacer/2) * ($size/2) !important;
                                                  }
                                                  }
                                                  }

                                                  @else if($breakpoint-direction == 'down') {
                                                  @include media-breakpoint-down($breakpoint) {
                                                  @if $direction == 'mb' {
                                                  margin-bottom: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'mt' {
                                                  margin-top: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'mr' {
                                                  margin-right: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'ml' {
                                                  margin-left: ($spacer/2) * ($size/2) !important;
                                                  }
                                                  }
                                                  }
                                                  }

                                                  @each $breakpoint in $breakpoint-list {
                                                  @each $breakpoint-direction in $breakpoint-direction-list {
                                                  @each $direction in $class-prefix-list {
                                                  @for $i from 1 through 5 {
                                                  .#{$direction}-#{$i}-#{$breakpoint}-#{$breakpoint-direction} {
                                                  @include spacer-dynamic($breakpoint, $direction, $i, $breakpoint-direction);
                                                  }
                                                  }
                                                  }
                                                  }
                                                  }


                                                  It will generate a css with classes like this:



                                                  @media (max-width: 1199px) {
                                                  .mb-3-lg-down {
                                                  margin-bottom: 1.125rem !important; } }

                                                  @media (max-width: 1199px) {
                                                  .mb-4-lg-down {
                                                  margin-bottom: 1.5rem !important; } }





                                                  share|improve this answer













                                                  If you are using bootstrap 4 and you are consuming the sass-files (rather than just importing the bootstrap css) you can use this i wrote when I wanted to solve the same problem:



                                                  $class-prefix-list: mt mb; //mr and ml can be added if needed
                                                  $breakpoint-direction-list: up down;
                                                  $breakpoint-list: xxs xs sm md lg xl;

                                                  @mixin spacer-dynamic($breakpoint, $direction, $size, $breakpoint-direction) {
                                                  @if($breakpoint-direction == 'up') {
                                                  @include media-breakpoint-up($breakpoint) {
                                                  @if $direction == 'mb' {
                                                  margin-bottom: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'mt' {
                                                  margin-top: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'mr' {
                                                  margin-right: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'ml' {
                                                  margin-left: ($spacer/2) * ($size/2) !important;
                                                  }
                                                  }
                                                  }

                                                  @else if($breakpoint-direction == 'down') {
                                                  @include media-breakpoint-down($breakpoint) {
                                                  @if $direction == 'mb' {
                                                  margin-bottom: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'mt' {
                                                  margin-top: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'mr' {
                                                  margin-right: ($spacer/2) * ($size/2) !important;
                                                  }

                                                  @if $direction == 'ml' {
                                                  margin-left: ($spacer/2) * ($size/2) !important;
                                                  }
                                                  }
                                                  }
                                                  }

                                                  @each $breakpoint in $breakpoint-list {
                                                  @each $breakpoint-direction in $breakpoint-direction-list {
                                                  @each $direction in $class-prefix-list {
                                                  @for $i from 1 through 5 {
                                                  .#{$direction}-#{$i}-#{$breakpoint}-#{$breakpoint-direction} {
                                                  @include spacer-dynamic($breakpoint, $direction, $i, $breakpoint-direction);
                                                  }
                                                  }
                                                  }
                                                  }
                                                  }


                                                  It will generate a css with classes like this:



                                                  @media (max-width: 1199px) {
                                                  .mb-3-lg-down {
                                                  margin-bottom: 1.125rem !important; } }

                                                  @media (max-width: 1199px) {
                                                  .mb-4-lg-down {
                                                  margin-bottom: 1.5rem !important; } }






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Aug 8 '17 at 12:57









                                                  WIRNWIRN

                                                  5041027




                                                  5041027























                                                      -1














                                                      Bootstrap doesn't provide something for managing margins or paddings, but you could do something like this: jsFiddle link. Where you set the margin to a div with visible-xs class.



                                                      <div class="container">
                                                      <div class="row">
                                                      <p>123123</p>
                                                      <div class="xs-margin visible-xs">
                                                      </div>
                                                      <p>asdasdadasd</p>
                                                      </div>
                                                      </div>


                                                      with css:



                                                      .xs-margin {
                                                      margin-bottom: 100px;
                                                      }





                                                      share|improve this answer




























                                                        -1














                                                        Bootstrap doesn't provide something for managing margins or paddings, but you could do something like this: jsFiddle link. Where you set the margin to a div with visible-xs class.



                                                        <div class="container">
                                                        <div class="row">
                                                        <p>123123</p>
                                                        <div class="xs-margin visible-xs">
                                                        </div>
                                                        <p>asdasdadasd</p>
                                                        </div>
                                                        </div>


                                                        with css:



                                                        .xs-margin {
                                                        margin-bottom: 100px;
                                                        }





                                                        share|improve this answer


























                                                          -1












                                                          -1








                                                          -1







                                                          Bootstrap doesn't provide something for managing margins or paddings, but you could do something like this: jsFiddle link. Where you set the margin to a div with visible-xs class.



                                                          <div class="container">
                                                          <div class="row">
                                                          <p>123123</p>
                                                          <div class="xs-margin visible-xs">
                                                          </div>
                                                          <p>asdasdadasd</p>
                                                          </div>
                                                          </div>


                                                          with css:



                                                          .xs-margin {
                                                          margin-bottom: 100px;
                                                          }





                                                          share|improve this answer













                                                          Bootstrap doesn't provide something for managing margins or paddings, but you could do something like this: jsFiddle link. Where you set the margin to a div with visible-xs class.



                                                          <div class="container">
                                                          <div class="row">
                                                          <p>123123</p>
                                                          <div class="xs-margin visible-xs">
                                                          </div>
                                                          <p>asdasdadasd</p>
                                                          </div>
                                                          </div>


                                                          with css:



                                                          .xs-margin {
                                                          margin-bottom: 100px;
                                                          }






                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Jun 8 '16 at 18:31









                                                          user3528269user3528269

                                                          316213




                                                          316213






























                                                              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%2f37710038%2fbootstrap-how-to-add-bottom-margin-for-mobile-screen-only%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

                                                              Xamarin.iOS Cant Deploy on Iphone

                                                              Glorious Revolution

                                                              Dulmage-Mendelsohn matrix decomposition in Python