

Bootstrap clearfix class with example
source link: https://www.laravelcode.com/post/bootstrap-clearfix-class-with-example
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Bootstrap clearfix class with example
In this article, I will show you how you can clear floated space and start new elements from new line.
If you use float property to element, it always float to left or right as you have set. The new elements you may want to start from new line but it may also start in beside floated elements. Here is below example.
Example:
<!doctype html>
<html>
<head>
<title>Without clearfix</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="border border-3">
<img src="https://hackthestuff.com/uploads/subCategories/1626256775898nginx.png" class="float-start">
<h1>Without clearfix</h1>
</div>
<p class="lead">This is new line and should start from new line.</p>
</div>
</body>
</html>

You can see <p> element is started after <h1> element which is not as you want. To prevent <p> element start direct after <h1> element, you need to clear the float. Bootstrap .clearfix class clear floated content within a parent element.
You just need to add .clearfix class to the parent element and it will fix the issue. Here is the example:
<!doctype html>
<html>
<head>
<title>With clearfix</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="border border-3 clearfix">
<img src="https://hackthestuff.com/uploads/subCategories/1626256775898nginx.png" class="float-start">
<h1>With clearfix</h1>
</div>
<p class="lead">This is new line and should start from new line.</p>
</div>
</body>
</html>

You can see p element started after clearfix class. I hope it will help you.
Author : Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Recommend
-
156
Froala Design Blocks Over 170 responsive design blocks ready to be used in your web or mobile apps. All blocks are based on the Bootstrap Library, and they are the bu...
-
7
Could not find class 'com.example.adapter.MyCursorAdapter' referenced from method com.example..
-
9
A Bootstrap 4 Two Column Example that Just Works Jul 26, 2019 I remain, alas, CSS Challenged. I'm from an era where the height of HTML layout was tables and once upon a time I know all the tricks including im...
-
4
Sep 9th, 2020Tales from Webdev Past - Clearfix × Floats × Cufon × Guestbooks × PNG Fix × More!👇 Download Show
-
10
Object level and Class level locks in Java with example This question is also important for experienced java developers to know about type of locks in multithreading. A...
-
6
Hello friend, Toady you will learn how to use bootstrap 5 gradient button. In this section we will not use any external or internal css classes , we will create gradient button using bootstrap 5 in build cl...
-
9
Angular Bootstrap Typeahead Example & DemoAutocomplete is a very important feature of the select box whenever items are too many, this help to easily search item using user typed character into text box, before the typeah...
-
7
A simple scrollable frame class for tkinter, including example usage. ...
-
12
Bootstrap 5 accordion example 5568 views 1 year ago Bootstrap Bootstrap accordion provides easy way to handle a i...
-
8
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK