Home » bootstrap » Bootstrap Sizing

Bootstrap Sizing

Bootstrap has a separate set of utilities for controlling the size of the element.

You can manage the width and height of the element as per the requirement.

Here, we will talk about the Boostrap Sizing utilities and discuss the various Bootstrap classes for the same.

, we will talk about the Bootstrap Sizing utilities and discuss the various Bootstrap classes for the same.

To understand the working better, we can first have a look at the CSS sizing properties.

These properties are used to control the normal height and width as well as maximum height and width.

So let’s have a look at the CSS sizing properties before we dive in to the Bootstrap concepts.

CSS Properties

CSS has following properties to control the sizing of the components:

  • height: For controlling the height of the element
  • max-height: For setting the maximum height of the element
  • max-width: For setting the maximum width of the element
  • min-height: For setting the minimum height of the set the element
  • min-width: For setting the minimum width of the element
  • width: For controlling the width of the element

Check the code below to get a good understanding of these properties:

Now that, you understand the basic sizing features in CSS. Let us get back to Bootstrap.

Bootstrap Sizing

Bootstrap lets you easily control the elements for its width or its height.

You can set these parameters relative to the parent components. Let’s check out some points that you need to know for Bootstrap Sizing utilities:

  • You can manage the width and height of the components using the $sizes Sass map present in the _variables.scss.
  • For width, we have the w-* classes and height we have the h-* classes. Where the * is replaceable by appropriate numbers
  • By default, Bootstrap supports the sizing for 25%, 50%, 75%, and 100%. Therefore, the * in the above point can be replaced with 25, 50, 75 or 100.

Modify those values as you need to generate different utilities here

Max-Width and Max-Height

Similarly, the max-width and max-height properties of CSS can also be controlled by following bootstrap clases:

  • mw-*: Sets the maximum width with the * value.
  • mh-*: Sets the maximum height with the * value.

The below code will illustrate the use these classes to control the maximum width and height for the value of 100%

Please follow and like us:
error