Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to the .pull-left and .pull-right classes in Bootstrap 4?

Tags:

bootstrap-4

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?

like image 492
Kevin J Avatar asked Oct 14 '22 18:10

Kevin J


People also ask

How do I pull a button right in Bootstrap 4?

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.

How do you pull right in CSS?

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.


Video Answer


1 Answers

Bootstrap 4

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;
}

Bootstrap 5

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/

like image 233
Robert Went Avatar answered Oct 16 '22 08:10

Robert Went