0

This is my css content :-

   <style type = "text/css">
       li
    {
        display:inline;
    }
    .carousel
    {
        position:absolute; 
        white-space:nowrap;

    }
    .sliderGallery
    {
        width:800px;
        overflow:hidden;
        height:100px;

    }
 </style>

This is my html content :-

 <div id="sliderGallery" class = "sliderGallery">

        <ul id = "carousel" class="carousel">
            <li>
                <img src ="Images/1.jpg" />
            </li>

            <li>
                        <img src ="Images/2.jpg" />


            </li>

            <li>
                    <img src ="Images/3.jpg" />

            </li>

            <li>
                        <img src ="Images/4.jpg" />

            </li>

            <li>
                        <img src ="Images/5.jpg" />

            </li>

            <li>
                                <img src ="Images/6.jpg" />

            </li>
        </ul>
      </div>

As you can see i have set overflow:hidden but still, my content is being displayed if it is more than 800px. Where am i wrong?

Thanks in advance :)

3 Answers 3

3

What about adding a height to the div too?

Also try removing position:absolute; on the carousel.

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

8 Comments

Yep. If you don't have a specified height, the container will just expand.
Hi, Sorry. It still doesn't work :(. I am posting the edited code.
Then it works. However i want it to be absolute only. Since i am manipulating left property of css using jquery. And unfortunately left property only works when position is absolute. I am actually developing a carousel.
Then set the overflow hidden and height/width on the carousel ul, or add position: relative to the sliderGallery div.
No i don't want to set overflow:hidden on ul. Please see this link :- apple.com/mac . See the carousel on top. If i set overflow:hidden on ul then how am i going to show the rest of <li> when slider is moved left and right. Please give some idea to tweak the container. I can't set overflow:hidden on ul. It works but then my whole application stops working. :(
|
2

Try changing .sliderGallery to #sliderGallery in your CSS

1 Comment

Oops! sorry i forgot to add classname. I changed it in my post. But still it is not working :(
0

Danixd above should be correct: setting position:relative on .sliderGallery (the div) will make the ul slide around inside it. Currently, it is sliding around relative to the outer container (or body if you don't have one). You can also try specifying an explicit width for the li.

Comments

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.