I have a <ul> with its <li>s aligned to the right. I’d like them to be positioned such that only about 20px of the element is showing on the right side of the <ul>, and on hover they go to their normal positions. This will be combined with overflow: hidden; on the container so the elements are partially hidden to begin with and slide in from the side (with CSS3 transitions).
In this jsFiddle example (overflow: visible for illustration) I was able to slide the elements in to the right position, but how do I align them such that they lie with 20px inside their container to start with? The best I could do was keep them right-aligned and push them all the way outside their container.
I played with changing the elements’ widths, but if they contain multiple words the text wraps and the height changes (or with overflow: hidden the words just disappear when the width is too small), which is unacceptable.
It’s acceptable (but less interesting and less preferable) to use fixed-width <li>s, if necessary, but I’d like to see other solutions.
If the UL itself has a fixed width, you could position the LI’s ({UL_width} – 20) pixels from the left of the UL. I would probably do something like…
The following CSS should give you the desired effect…
Something along those lines should do the trick. Then just do a rollover to adjust your left property of the ul li span.
NEW CSS