I have a <ul/>
that is set up horizontally, and is contained within a <div/>
so that when the <ul/>
overflows, you can scroll the <div/>
to see the rest. It looks something like this:
HTML:
<div>
<ul>
<li>HEADER</li>
<li>Item1</li>
<li>Item2</li>
<!-- Additional items -->
</ul>
</div>
CSS:
div {
white-space:nowrap; overflow-x:scroll; width:100%;}
ul {
list-style-type:none; }
li {
display:inline-block; }
Is there a way to "fix" the first element of the <ul/>
in place while scrolling the overflow?
The first element (with the text "HEADER"
) should stay in place while the rest of the items scroll. I realize there may not be an "elegant" solution for this.
I tried just making the "HEADER"
item a separate element outside of the <ul/>
, but since I have the <ul/>
width set to 100%
, it makes the entire <ul/>
overflow outside the browser window.
I tagged the question with jquery because a) I'm already using jquery in my application, and b) I think that it might be possible to $.clone()
the element and "fix" it in place. That may be the answer, but I'm struggling with the specific implementation or whether there is a simpler way to accomplish this.