CSS padding overrides overflow?

半世苍凉 提交于 2019-11-28 13:36:49

In the default content-box box model on a display: block element, padding and height are added together to determine the total height of the element. overflow only affects things outside the box (outside of height + padding + border).

If you want border and padding subtracted from specified height rather than added, use box-sizing: border-box.

Like this

demo

css

*{
    margin:0;
    padding:0;
}
#agendaTitle{
    margin:0;
    padding:0.75em 0em 0em 0.75em;
    height:3em;
    overflow:hidden;
    background-color:#ff00ff;
}

You have set the height to 3em, so it will show the final height of ( 3em + 20em ).

And overflow will restrict only for height i.e 3em.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!