- Float property [1]
- Changes the behavior of that element and the block level elements that follow it in normal flow.
- Removing normal flow and element moved from left to right instead.
- The surrounding content floats around the floated item.
- Property values
- <left>, <right>, <none>, <inherit>
- Block-level elements behavior with float or display property
- Float property behaviors with parent
- Float element naturally collapses its parent element. The width of a child element crosses the parent width they don't depend on child element float property. But height is collapsed when float is present in a child element. Complication
- Solution 1
- Add <div style="clear:both">.
- Just create a new line.
- Solution 2
- Solution 3
- Behavior with image
- Suppose your element has inline properties like image. Use float(left/right) with img then text wrap image. Image 3.
- Brittle
- Bottom margin mismatch: Use padding bottom in parent or use hr with margin bottom. If double margin appears allow inline-block with float element.
- Some pixel cross: Add height/width with child element.
- Image cross parent div widely : Use overflow hidden.
⌚ CSS3 Essentials
No comments:
Post a Comment