I'm having a bit of trouble with a couple of <ul>
list objects on one of my pages.
I have two <ul>
list containers that are populated from the client browser. Unrelated to this discussion, these two containers will allow for users to drag-and-drop <li>
options left<->right from each container, and will be used for a form of manual sorting.
My problem is that either of these lists may contain 0 to upwards of 60 items. When there are many list items in one of the list containers, the parent grows well past the size screen and scroll bars appear, while the <ul>
container grows as large as it needs to be.
I'd prefer for the scroll bars to be on the <ul>
objects only (and function properly.)
I've googled this, and I've found multiple answers regarding forcing content to the size of a parent container, but most examples usually involve <div>
objects and I'm not sure if there is something different with the <ul>
container which causes it to behave differently.
Below is my pertinent code.
HTML
...
<ul class="col_selector_container" id="ulUnusedColumns"></ul>
<ul class="col_selector_container" id="ulUsedColumns"></ul>
...
This content is contained in a third-party Telerik control. The content area of the Telerik control is a div that is sized to fit the available content area, with or without content provided by the developer. However, the content area does grow larger if the internal content doesn't fit and, thus, the automatic scroll bars appear when the <ul>
containers are populated and over-sized.
CSS
ul.col_selector_container
{
overflow-y: scroll;
list-style-type: none;
height: 100%;
width: 300px;
display:inline-block;
vertical-align:top;
padding-left: 0px;
}
Note that the height: 100%
doesn't appear to do anything. The list will grow or shrink to match the height of the internal content, not the height of the parent container. Also, overflow-y: scroll;
doesn't do anything other than show the scroll bars, which is pointless if the UI is just going to resize the list.
How can I fix this?
ADDITIONAL NOTES
I am using jquery & jqueryui for for sortign and working with UI elements. A good answer can involve using one of these tools if there is an option within these tools that can fix my problem, but that's certainly not required. Pertaining to this questino, JQuery never touches the layout of these object, other than inserting <li>
objects, derived from my data list at runtime.
For those wanting an example, the best I can give is an example of the problem.
Here is a JSFiddle. Notice that the <ul>
list is populated so that the content region of the fiddle has a scroll bar. Also note the pointless scroll bar on the list? How can I make it so that the content area doesn't need a scroll bar because the <ul>
sizes itself to the content window (with more or less list items) and you can scroll through the list content when the list region is to large.
` elements to size properly, but I've had no issue with *most* divs.
– RLH Jan 05 '16 at 16:32` elements. Basically, I can't seem to do anything to FORCE them to a specific height by a percent. Hardcoded pixel values work, but not percents. I wonder if this has to do with dynamically loading content?
– RLH Jan 05 '16 at 16:42