Forums

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

Home Forums CSS Half background on div

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #33084
    Roy972
    Member

    Hey, I have a div with a background, but I want the background just on the half of the div. how can I do it? (without any other div)

    #73399
    TheDoc
    Member

    If you know the height of the background, you can use background-position to adjust it. So, if the background has a height of 500px, you could do this:

    div { background-position: 0 -250px; }
    #73383
    Roy972
    Member

    It’s right, but if I want that the background (for example 2px X 2px) will be duplicated just on the half div (for example the width of the div is 500px and I need just on 250px). thank you.

    #73384
    TheDoc
    Member

    So you want it split horizontally? Then just switch the numbers around…

    #73377
    Roy972
    Member

    My fault sorry, I mean if I don’t know the size of the div.. there is a way to do it?

    #73375
    TheDoc
    Member

    Oooohhh I see what you mean. I think that would need some multi-div activity, or some sort of JS solution.

    #73350
    furrball1383
    Member

    well multi div might work better, make a main div wrapping two divs, give the two inner divs z values. one of those divs is going to be the background so use width:50% in the css for the div then set the background image for this dive and set it to repeat as you wish through the whole div. The other div will hold your content. I believe that should work :D someone correct me if I’m wrong :D

    Without knowing what you want to use it for or how exactly it affects your site, its hard to visualize the solution you’re looking for, so sorry if i totally missed your point.

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