css("float") code example
Example 1: float none css
.titanic {
float: none;
}
Example 2: Float element should has parent element that defined clear property.
.clearfix::after {
content: " ";
display: block;
height: 0;
clear: both;
}
Example 3: how to clear floats
This is the code
.float-wrapper::after {
content: "";
clear: both;
display: block;
}
---------------------------------------------------------------
Explanation:
.float-wrapper -> is some parent element that wraps the floating items
example:
<div class='float-wrapper'>
<div class='floating-item'> </div>
<div class='floating-item'> </div>
....
</div>
::after adds an element after the .float-wrapper, that
has no content and clears floats from the both sides, making sure,
other sections are not affected by floats
Example 4: float inf in python
float('inf')
float('-inf')
Example 5: html code to float image right
<!DOCTYPE html>
<html>
<body>
<h2>Floating Images</h2>
<p><strong>Float the image to the right:</strong></p>
<p>
<img src="smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;">
A paragraph with a floating image. A paragraph with a floating image. A paragraph with a floating image.
</p>
<p><strong>Float the image to the left:</strong></p>
<p>
<img src="smiley.gif" alt="Smiley face" style="float:left;width:42px;height:42px;">
A paragraph with a floating image. A paragraph with a floating image. A paragraph with a floating image.
</p>
</body>
</html>
Example 6: css floaat
.myelement {
float: left;
}