CSS float lead to solutions set the background color invalid

float floating height will collapse parent element, parent element can not be softened, resulting in background color can not be softened

Solution:

  1. Set the height of the parent element
  2. The parent element is set overflow: hidden Clear float
  3. The parent element is also set to the floating float
  4. Add the code before the end tag: <div style = "clear: both"> </ div>

Guess you like

Origin www.cnblogs.com/gsdoublel/p/11260564.html