tags:

views:

40

answers:

3

Hello,

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 :)

+2  A: 

Try changing .sliderGallery to #sliderGallery in your CSS

Jimmy
Oops! sorry i forgot to add classname. I changed it in my post. But still it is not working :(
Ankit Rathod
+3  A: 

What about adding a height to the div too?

Also try removing position:absolute; on the carousel.

danixd
Yep. If you don't have a specified height, the container will just expand.
Ryan Kinal
Hi, Sorry. It still doesn't work :(. I am posting the edited code.
Ankit Rathod
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.
Ankit Rathod
Then set the overflow hidden and height/width on the carousel ul, or add position: relative to the sliderGallery div.
danixd
No i don't want to set `overflow:hidden` on ul. Please see this link :- http://www.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. :(
Ankit Rathod
Did you add position: relative; to the div?
danixd
Great! You finally did my job. Voted. But why should i set it to positon:relative? Isn't it postion:relative by default?
Ankit Rathod
You would think so! But no, always add position: relative on the parent of the absolutely positioned element. Good luck!
danixd
Thanks danixd .
Ankit Rathod
A: 

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.

electrichead