tags:

views:

44

answers:

3

I have an issue with a site I am working on where the right wrapper keeps dropping down below the site. Obviously I want it to stay on the right hand side.

I've coded up a test case which shows my issue (I think) and I'm wondering if there is a better way to do things.

The website url is http://www.musicworkshop.co.nz/

Below is the test case which (I think) is the cause of my issue, however it may not be. The pink box drops down if it does not fit within the page width.

I've also included a diagram of what I'm trying to achieve along with a screenshot of the right wrapper not where it should be.

Is there a better way to do this?

John

<html>
    <head>
        <title> Test page </title>
        <link rel="stylesheet" href="test.css" type="text/css" />
    </head>
    <body>
        <div id="superbox">
            <div id="box1">
            </div>
            <div id="box2">
            </div>
            <div id="box3">
            </div>
            <div id="box4">
            </div>
            <div id="box5">
            </div>
            <div id="box6">
            </div>
        </div>
    </body>
</html>

#superbox{
    width: 1000px;
    height: 100px;
    margin: 0 auto;
}

#box1{
    height: 100px;
    width: 200px;
    background: red;
    float: left;
}

#box2{
    height: 100px;
    width: 200px;
    background: yellow;
    float: left;
}

#box3{
    height: 100px;
    width: 200px;
    background: blue;
    float: left;
}

#box4{
    height: 100px;
    width: 200px;
    background: green;
    float: left;
}

#box5{
    height: 100px;
    width: 200px;
    background: grey;
    float: left;
}

#box6{
    height: 100px;
    width: 200px;
    background: pink;
    float: left;
}

alt text

alt text

+1  A: 

Since all your boxes are 200px wide go for a %.

Saurabh
that's a good suggestion for the example I gave, but it doesn't apply to the real site.. I guess my test example wasn't accurate enough. I'll add a screenshot of the actual site to my question
John Deverall
+1  A: 

if it doesn't fit into the page width, this is the way float works... if you want to have the boxes in one line whatever happens, set your superbox with to the with of all boxes (which is 200*6 = 1200 / not 1000).

oezi
I thought of this solution myself, but tried it and it didn't work.What happens for me when I try this is that the boxes list vertically down the screen instead of horizontally across it. Is this not what you expect to happen?
John Deverall
+1  A: 

EDITS:

Looking at your example site I think you mean when the viewwindow is small that you want the div to go off-screen. In your case the best solution is to make that repeating image the background-image of your body.

Something like:

body { background: #6593aa url('http://www.musicworkshop.co.nz/templates/musicworkshop/images/right_repeater.png') repeat-x; }

And make sure to take the backgrounds off your other divs. You'll probably want to pick a different image to repeat with too rather than just the right segment. I can see you were trying to get it to match up with the header nicely but the way you are going about it just won't work. My best solution is to use a transparent background on your leftwrap and rightwrap near header (use a .gif or .png with transparency for your rounded corner rather than the current image with the bit of "amplitude wave" in the background).

Summary:

  1. Remove all wrapper etc. backgrounds.
  2. Change the "rounded corner" images to have a transparent background.
  3. Remove your "repeating" divs.
  4. Apply that CSS above to the body.

Original:

What's your desired behaviour? For superbox to go 1200px? Unfortunately you can't have fixed sizes and "auto-grow".

If you want 'superbox' to grow to fit its children then don't specify a width (i.e. leave it width:auto).

If you instead want the children to resize if they are too large for 'superbox' use percentage widths on them.

It sounds like you want your boxes to stay their current size and not wrap. Well try and imagine what would happen if you put a new div under 'superbox' and wrapping your 'box_'es that had a width of 1200px. It's going to make 'superbox' grow to wrap around it so at the end of the day you might as well just make 'superbox' this larger width in the first place!

Graphain
yeah, ignore my testcase, it might not be my issue. I don't actually know what my issue is. If you look at www.musicworkshop.co.nz you will see (or hopefully see) that the rounded end to the header is missing. Also the left and right repeaters aren't lining up. I've added an image of what I'm aiming for in the original posting.
John Deverall
Yeah my CSS example achieves what you are looking for by doing away with the repeater divs and using the body background.
Graphain
See my "summary" bit and let me know if any of it is confusing or doesn't do what you need.
Graphain
For reference, your test case is technically correct and matches what you think is the issue (you can't get a div to go off-screen, which is entirely true unless you give it a large size in which case you'll get horizontal scrollbars). However, your real issue (I believe) is you want a repeating page-header background which is better achieved by the summary changes I've listed.
Graphain
Hi Graphain, I really appreciate all your help. I'm not actually have so much of an issue with the repeater. It's the rounded corner image on the right end of the header, what I call the wrapper. I've posted above a screenshot showing that the wrapper is just not there.
John Deverall
Ah okay - I get a completely different result in IE7 (not my default browser) which is why I thought that was your main issue. I get what you call the wrapper but not the auto-repeating on either side which is totally what I would expect given the code as your middle_wrapper is filled precisely by its contents and they all have widths. In FireFox it either works perfectly, or the left "wrapper" breaks if the page is too small when I first load the page. I have something for the next 90 minutes but I'll have a look at it after that and will post a fix.
Graphain