In the newest version the pull-left and pull-right have been replaced by .pull-{xs,sm,md,lg,xl}-{left,right,none}
That means that instead of writing a simple class="pull-right"
, I will have now to write class="pull-md-right pull-xl-right pull-lg-right pull-sm-right pull-xs-right"
Is there a less tedious way to do it?
Answer: Use the text-right Class You can simply use the class . text-right on the containing element to right align your Bootstrap buttons within a block box or grid column. It will work in both Bootstrap 3 and 4 versions.
The right property affects the horizontal position of a positioned element. This property has no effect on non-positioned elements. If position: absolute; or position: fixed; - the right property sets the right edge of an element to a unit to the right of the right edge of its nearest positioned ancestor.
The classes are float-right
float-sm-right
etc.
The media queries are mobile-first, so using float-sm-right
would affect small screen sizes and anything wider, so there's no reason to add a class for each width. Just use the smallest screen you want to affect or float-right
for all screen widths.
Official Docs:
Classes: https://getbootstrap.com/docs/4.6/utilities/float/
Updating: https://getbootstrap.com/docs/4.6/migration/#utilities
If you are updating an existing project based on an earlier version of Bootstrap, you can use sass extend to apply the rules to the old class names:
.pull-right {
@extend .float-right;
}
.pull-left {
@extend .float-left;
}
With Bootstrap 5, float classes still exist, but -left
and -right
are replaced with -start
and -end
.
Responsive versions are still available such as .float-md-start
, .float-lg-none
.
Official Bootstrap 5 float docs: https://getbootstrap.com/docs/5.1/utilities/float/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With