Why does css change the div when I add an element with a block style to it?

When I delete the screen: the block from p inside the div, it ignores the top edge or its own height or something like that. He snuggles next to the element above him. Does anyone know why?

The div is expanded, the element above is not.

-1
source share
1 answer

String elements simply do not account for vertical margins or height. Block elements.

Edit:

In response to the comments, it seems that there are two problems.

  • You have two elements with id='generals' . Change this to class='generals' .
  • Add overflow: hidden to your generals style. All elements inside it float and therefore do not relate to the height of the element. Adding overflow: hidden changes the way the element is displayed, clearing all the floats inside it.
0
source

All Articles