1

I have a container div. Inside that div are three graphs aligned at 700px intervals (the width of the container). The idea is that the other 2 graphs will be hidden off screen which I can then, with jQuery, slide across when a user interacts with various controls on the web page.

A simplified version of my code is like so:

Style

    #graphcontainer {
        height: 260px;
        overflow: hidden;
        width: 700px;
    }
    .graph {
        position: absolute;
    }

HTML

<div id="graphcontainer">
        <div class="graph" style="left: 0px;"></div>
        <div class="graph" style="left: 700px;"></div>
        <div class="graph" style="left: 1400px;"></div>
</div>

For some reason the second and third graphs, which are positioned off to the right, are still visible! How do I ensure they are not visible?

3 Answers 3

3

First you have to set, position:relative for the parent. Then, you have to set the height of the parent.

Demo: http://jsfiddle.net/Scfdk/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks this worked, thanks also for the jsfiddle link it helped
3

You need to add position: relative; and set a height to the element you have overflow set to hidden on.

3 Comments

I don't think that setting only position:relative will solve the problem.
Yeah you're right. I noticed and was about to edit my post although you already posted including the height of the parent element. Thank you.
I had actually already set height (I omitted it as I didnt think it was necessary). +1 for help. Thanks.
0

if you want to hide a div, have you considered "display: none"? For example,
<div class="graph" style="display: none"/>

1 Comment

I usually do this but as I want to animate the graphs sliding around I cannot use display

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.