css child padding makes it draw out side the parent

后端 未结 5 951
醉话见心
醉话见心 2020-12-23 21:19

Applying padding to child elements is making the child draw over the boundaries of its containing parent. Can you please explain the size consideration in margin,padding an

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 21:31

    Can be solved without making any change in a tag. Just add overflow: hidden; property to div element.

    div {
      margin-top:90px;
      margin-left:90px;
      background-color:#676896;
      overflow: hidden; /*expends its height if not fixed*/
    }
    

    Updated fiddle here: http://jsfiddle.net/NkXUW/52/

提交回复
热议问题