How do I keep a DIV from expanding to take up all available width?

前端 未结 5 697
礼貌的吻别
礼貌的吻别 2021-02-18 12:54

In the following HTML, I\'d like the frame around the image to be snug -- not to stretch out and take up all the available width in the parent container. I know there are a coup

5条回答
  •  囚心锁ツ
    2021-02-18 13:26

    The beige rectangle is so wide because you have display: block on the span, turning an inline element into a block element. A block element is supposed to take up all available width, an inline element does not. Try removing the display: block from the css.

提交回复
热议问题