Text wraps around floating div but borders and
s do not

后端 未结 5 2030
南笙
南笙 2021-01-04 05:09

I have a div that is float: right and it is inside a parent div. There are p elements inside that same parent div also, and the text wraps around t

5条回答
  •  臣服心动
    2021-01-04 06:15

    Check out the fiddle...

    http://jsfiddle.net/UnsungHero97/8BwGB/3/

    What I did here was give the floated element a z-index CSS property, which will put it "above" the non floated element (which has a smaller valued z-index) and the


    will not go above the floated element.

    In regards to getting it as wide as the text, in my example it is as wide as the text, but I'm not sure if that holds across browsers (I'm on Chrome). Let me know if it doesn't.

    I hope this helps.
    Hristo

    p.s. excellent mspaint skillz :)

提交回复
热议问题