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

前端 未结 5 708
礼貌的吻别
礼貌的吻别 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:27

    The right way is to use:

    .pictureframe {
        display: inline-block;
    }
    

    Edit: Floating the element also produces the same effect, this is because floating elements use the same shrink-to-fit algorithm for determining the width.

提交回复
热议问题