Hướng dẫn dùng w3schools float trong PHP
More "Try it Yourself" examples below. Show Definition and UsageThe Note: Absolutely positioned elements ignore the Note: Elements next to a floating element will flow around it. To avoid this, use the clear property or the clearfix hack (see example at the bottom of this page). Show demo ❯
Browser SupportThe numbers in the table specify the first browser version that fully supports the property.
CSS Syntaxfloat: none|left|right|initial|inherit; Property Values
More ExamplesExampleLet image be displayed just where it occurs in the text (float: none): img { Try it Yourself » ExampleLet the first letter of a paragraph float to the left and style the letter: span { Try it Yourself » ExampleUse float with a list of hyperlinks to create a horizontal menu: .header, .footer { .column { .clearfix::after { .menu {width: 25%;} Try it Yourself » ExampleUse float to create a homepage with a header, footer, left content and main content: .header, .footer { .column { .clearfix::after { .menu {width: 25%;} Try it Yourself » ExampleDo not allow floating elements on the left or the right side of a specified element: img { p.clear { Try it Yourself » ExampleIf a floating element is taller than the containing element, it will overflow outside its container. It is possible to fix this with the "clearfix hack": .clearfix::after { Try it Yourself » Related PagesCSS tutorial: CSS Float HTML DOM reference: cssFloat property The CSS The CSS The float PropertyThe The
In its simplest use, the Example - float: right;The following example specifies that an image should float to the right in a text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac...Example - float: left;The following example specifies that an image should float to the left in a text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac...Example - No floatIn the following example the image will be displayed just where it occurs in the text (float: none;): Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac...Example - Float Next To Each OtherNormally div elements will be displayed on top of each other. However, if we use Example div { .div1 { .div2 { .div3 { Try it Yourself » |