Jump to content

UL Horizontal Scrollbar


TrueColors

Recommended Posts

Below is my css

ul#attachmentList {
    background:#fff;
    height:40px;
    padding: 0;
    list-style: none;
    width: 705px;
    border:1px solid #ABADB3;
    overflow-x: scroll;
}
ul#attachmentList:hover {
    border-top:1px solid #3B7BAD;
    border-left:1px solid #A4C9E3;
    border-right:1px solid #A4C9E3;
    border-bottom:1px solid #A4C9E3;
}
ul#attachmentList li {
    margin: 2px 0 2px 2px;
    float: left;
    background: AliceBlue;
    padding: 0 10px;
    text-align: center;
    height: 20px;
    line-height: 20px;
    
    -moz-border-radius: 5px;
    border-radius:5px;
    -webkit-border-radius:5px;
}

Now when I keep adding LI's it doesn't make use of the horizontal scrollbar (although the bar is visible). The li's just go beneath each other. I want it to make use to the scrollbar.

 

What am I doing wrong?

 

Link to comment
Share on other sites

I put the scrollbar on the div. I used JavaScript to loop through the LI's and add the widths, including padding's and any margins. Then that total width is the width of the UL.

 

The JavaScript is:

		<script type="text/javascript">
		function updateULWidth()
		{
			var item_width = 0;

			$("ul#attachmentList li").each(function() {
				var wide = $(this).width();

				$(this).css({'width' : wide + "px"});

				item_width += parseInt($(this).css('padding-left')) + parseInt($(this).css('padding-right')) + parseInt($(this).css('margin-left')) + parseInt($(this).width());
			});

			$("ul#attachmentList").css({'width' : item_width + "px"});
		}
	</script>

Link to comment
Share on other sites

Oei Sorry i am as good in javascript (within the css forum) as playing rugby without legs and being blindfolded.

 

I assume your nifty JavaScript outputs html in the end right? post that here. I find it more than difficult to imagine how this would look. Maybe got an on-line example otherwise would save a lot.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.