This tutorial aims to guide you in customizing the size and color of Bootstrap Icons using CSS. Bootstrap icons are SVGs, so they can be styled with CSS, including size and color. By the end of this tutorial, you will be able to alter these properties to better match your website's design and aesthetics.
No prior knowledge is required, but a basic understanding of HTML, CSS, and Bootstrap could be beneficial.
Size: Bootstrap icons' size can be adjusted using CSS properties like width
and height
. Using the font-size
property will also scale the icon because they are SVGs.
Color: The fill
property is used to change the color of Bootstrap icons. Setting this property will change the icon color.
Best Practices: Always aim for consistency in your website's design. When changing icon sizes and colors, ensure that they align with your site's overall aesthetic.
Here's an example of how you can customize your Bootstrap icons:
HTML:
<i class="bi bi-alarm-fill"></i>
CSS:
.bi-alarm-fill {
width: 50px;
height: 50px;
fill: red;
}
In this example, we first select the icon using its class, then we set width
and height
to 50px
and fill
to red. This will make the icon larger and change its color to red.
In this tutorial, we've learned how to customize the size and color of Bootstrap Icons using CSS. You now know how to use the width
, height
, and fill
properties to alter the size and color of these icons.
The next step would be to learn more about CSS and Bootstrap, such as how to use Bootstrap's built-in classes to further style your website. You can refer to the official Bootstrap documentation for more information.
Exercise 1: Customize the size of the bi-check
icon to 40px
by 40px
and change its color to green.
css
.bi-check {
width: 40px;
height: 40px;
fill: green;
}
bi-check
icon and sets the width
and height
to 40px
and fill
to green.Exercise 2: Increase the size of the bi-x-circle-fill
icon to 60px
by 60px
and change its color to red.
css
.bi-x-circle-fill {
width: 60px;
height: 60px;
fill: red;
}
bi-x-circle-fill
icon and sets the width
and height
to 60px
and fill
to red.For more practice, try to customize different Bootstrap icons and play around with the width
, height
, and fill
properties.