Bootstrap: Expand `position-fixed` into responsive, ie `position-fixed-lg-up`

Created on 23 Feb 2019  路  2Comments  路  Source: twbs/bootstrap

I dug around an hour, sure I'd find this, tho i didn't. It is small, tho it would help responsive layout. In my case, I have a nav sidebar, fixed when 'lg' and 'sm', but i need to make it display as block on tablets and phones.
Thank you.

<header class="position-fixed[-md-up|-md-lg-xl]">
  <nav>
  </nav>
</header>
css feature v5

Most helpful comment

In v5 you will be able to use our build in utility API:

$utilities: (
  "position": (
      property: position,
      responsive: true,
      values: static relative absolute fixed sticky
  ),
);

Which will generate classes like .position-md-fixed or .position-sm-relative.

All 2 comments

To get it more into Bootstrap philosophy I would more likely do p-[breakpoint]-[value], see Display Property.

_utilities/_position.scss_:

$positions: static, relative, absolute, fixed, sticky;

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

    @each $value in $positions {
      .p#{$infix}-#{$value} {
        position: $value !important;
      }
    }
  }
}

In v5 you will be able to use our build in utility API:

$utilities: (
  "position": (
      property: position,
      responsive: true,
      values: static relative absolute fixed sticky
  ),
);

Which will generate classes like .position-md-fixed or .position-sm-relative.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cvrebert picture cvrebert  路  3Comments

ghost picture ghost  路  3Comments

matsava picture matsava  路  3Comments

IamManchanda picture IamManchanda  路  3Comments

leomao10 picture leomao10  路  3Comments