sunmingtao / sample-code

3 stars 4 forks source link

What is the purpose of float:left and float:right? #91

Closed sunmingtao closed 4 years ago

sunmingtao commented 4 years ago

float:left puts the element at the leftmost under its parent element. float:right puts the element at the rightmost under its parent element.

<html lang="en">
    <head>
        <style>
            #s1 {

            }
        </style>
    </head>
    <body>
        <p>Paragraph one <span id="s1">ABCDE</span> Paragraph two</p>
    </body>
</html>

f1

#s1 {
    float: left;
}

f2

#s1 {
    float: right;
}

f3