If the floating left block is too high : float layout « Layout « HTML / CSS






If the floating left block is too high

 



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
    <head>
        <title></title>
        <style rel='stylesheet' type='text/css'>

div#container {
    border: 1px solid black;
    margin: 0 20px;
    background: pink;
    padding: 5px;
}

div#float {
    text-align: center;
    float: left;
    width: 150px;
    height: 150px;
    border: 1px solid blue;
    background: gold;
}
div.content {
    background: yellow;
    border: 1px solid  purple;
}
div#clear {
    border: 1px solid red;
    background: orange;
    clear: both;
}        
        </style>
    </head>
    <body>
        <div id='container'>
            <div id='float'>
                Float text. 
            </div>
            <div class='content'>
                Content text. 
            </div>
            <div class='content'>
                Content text. 
            </div>
            <div class='content'>
                Content text. 
            </div>
            <div id='clear'>
                Clear text. 
            </div>
            <div>
                Another div.
            </div>
        </div>
    </body>
</html>

 








Related examples in the same category

1.You can float any element using float:left or float:right.
2.A float element is removed from the normal flow.
3.Left floats indent adjacent content to the right,
4.right floats indent content to the left.
5.float left and margin left 34%
6.floats and percentage width
7.CSS: Left and right on the same line
8.Clearing Floats
9.When a float cannot fit next to another float, it moves down below it.
10.width sets the width of the float element.
11.height sets the height of the float.
12.height:auto is the default value and shrinkwraps the float to the height of all its child blocks or lines.
13.A positive margin pushes the float element away from its point of alignment
14.A positive margin pushes other floats and inline content away from it.
15.A negative margin pulls the float element to the other side of its point of alignment
16.A negative margin pulls other float elements and inline content closer.
17.Use width:auto, left:0, and right:0 to stretch an absolute element to the left and right sides of its closest positioned ancestor.
18.Use height:auto, top:0, and bottom:0 to stretch an absolute element to the top and bottom of its closest positioned ancestor.
19.Float Right - cleared right
20.Float Right - NOT cleared
21.Float and clear
22.Float from left one by one
23.Tag sequence and floating
24.Fluid Layout with float