Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to wrap backgrounds around floats?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #31316
    madseckert
    Member

    Hi I have a h2 element after a floated(left) div.
    I have set a background color to the h2 element, and here lies my problem: The text wraps nicely around the div but the background continues right behind the div, and since my div is transparent it’s not very pretty.
    I know it’s not a browser flaw, and that the background acording to the standard should do this, but: How can i fix this?

    I have tried setting the display to inline, but then the background color doesn’t extend to the far right (and also this for some reason stops the text from wrapping at all in Chrome).

    Any ideas would be appreciated :)

    #65142
    dhechler
    Member

    would you happen to have a link so we can look at it?

    #65143
    madseckert
    Member
    #64404

    as a quick fix you can add

    margin-left:210px;

    to the top two h2 elements.

    I wil be looking more for a better solution.

    #64377
    dhechler
    Member

    you could float the h2 elements left. That is also a quick fix. Or, as Brett_Santore said, use the margin-left statement. You could also set a width for them.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.