Bootstrap: Responsive .btn-block

Created on 2 Sep 2016  路  8Comments  路  Source: twbs/bootstrap

I love the responsive float classes in v4, but I was wondering if a similar concept could be applied to the .btn-block class. Here is a demo page which, as an example, has paging buttons. Without the convenience of a .btn-[size]-block class, you end up duplicating markup. (I only made the smallest size for the sake of the example.)

http://codepen.io/peiche/pen/wzvEyJ

css feature v4 v5

Most helpful comment

I went ahead and made the PR #21720.
It generates the responsive btn-*-block but not the vertical spacing.
The docs now mention to use the spacing utilities instead.

All 8 comments

Duplicate of #13647.

The tricky part would be the vertical spacing between btn-{breakpoint}-block here:

.btn-block + .btn-block {
  margin-top: $btn-block-spacing-y;
}

I would force to create all the combination for the different responsive classes, for each breakpoints. A total of 125 selector to handle the spacing...if we have 5 breakpoints...

Unless we decide to get rid of it and rely on spacing utilities instead

For information this is what the scss would look like to handle the responsive btn-{breakpoint}-block and the spacing. Nasty...

@function breakpoint-infix-up($name, $breakpoints: $grid-breakpoints) {
  @return if(breakpoint-max($name, $breakpoints) == null, "", "-#{$name}");
}

@each $breakpoint in map-keys($grid-breakpoints) {
  @include media-breakpoint-down($breakpoint) {
    $infix: breakpoint-infix-up($breakpoint, $grid-breakpoints);

    .btn#{$infix}-block {
      display: block;
      width: 100%;
      @each $breakpoint2 in map-keys($grid-breakpoints) {
        $infix2: breakpoint-infix-up($breakpoint2, $grid-breakpoints);

        + .btn#{$infix2}-block {
          margin-top: $btn-block-spacing-y;
        }

        .btn#{$infix2}-block + & {
          margin-top: $btn-block-spacing-y;
        }
      }
    }
  }
}

I went ahead and made the PR #21720.
It generates the responsive btn-*-block but not the vertical spacing.
The docs now mention to use the spacing utilities instead.

Definitely would like to see responsive btn-reset or something of the sort.

Just add white-space: normal; to your .btn class.

It's a shame #21720 was closed. This feature really makes sense for buttons, especially since there is responsive utility for most other things.

It should be possible to find a non-breaking middle-ground based on #21720?

We can indeed achieve this with utility classes these days, like @pvdlg mentioned.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kamov picture kamov  路  3Comments

IamManchanda picture IamManchanda  路  3Comments

devfrey picture devfrey  路  3Comments

tiendq picture tiendq  路  3Comments

alvarotrigo picture alvarotrigo  路  3Comments