Stop text from wrapping around image

前端 未结 5 1227
没有蜡笔的小新
没有蜡笔的小新 2021-02-03 14:24

I want to stop text from wrapping around image. Is there any way to do this without using margin?

5条回答
  •  情深已故
    2021-02-03 14:51

    You'll have to wrap your text in its own container.

    Since your is floated to the left, you can use overflow: hidden on your newly-added container to achieve no wrapping of the text.

    However block elements shouldn't be descendants of elements, you may want to rethink this tag.

    img {
        width:100px;
        height:67px;
        float:left;
    }
    div {
        overflow:hidden;
    }
    Text here. Text here. Text here. Text here.
    Text here. Text here. Text here. Text here. Text here. Text here.
    Text here. Text here. Text here. Text here.Text here. Text here.Text here. Text here.Text here. Text here.Text here. Text here.
    Text here. Text here.Text here. Text here.Text here. Text here. Text here. Text here. Text here. Text here.
    Text here. Text here. Text here. Text here. Text here. Text here.
    Text here. Text here. Text here. Text here.Text here. Text here.Text here. Text here.Text here. Text here.Text here. Text here.
    Text here. Text here.Text here. Text here.Text here. Text here.

    JSFiddle

提交回复
热议问题