Ben Fenwick Ben Fenwick - 2 years ago 60
HTML Question

How can I get an absolute element to float right within its parent?

So, I'm trying to get a dropdown to work as part of a menu. I have a ul with a few li elements added on the left and then I want to have an li element float to the right. I was doing this using relative position before, but now I want it to be able to overflow and display over anything below it.

I found this question:
CSS: Overflow Auto and Z-index
and found out you have to use absolute position to get this sort of overflow to happen. So, how would I do this?

This is the basic code structure:

<li id="right_item1"/> (relatively positioned)
<li id="absolute_position"/> (absolutely positioned, floating right)

Answer Source

This should work for you.

    position:relative; // You need this


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download