Why does break outside
when margin and padding is applied?

前端 未结 3 1623
礼貌的吻别
礼貌的吻别 2021-02-19 09:03

I know this is very basic CSS. How do I keep the span contained within the div? At the moment, the span extends outside the top and bottom of the div.

3条回答
  •  梦如初夏
    2021-02-19 09:23

    To answer your question, this isn't just an issue with padding or margin, but also with width, display, and the box model.

    jsFiddle

    span {
        display: inline-block;
    }
    

    This will honor any padding, margins, or widths you apply to the span.

提交回复
热议问题