I have a div with a fixed position (a top panel) which shall also contain a settings menu at the far right (currently via floating).
When hovering over the settings-image, I want to display a menu below the image. I want the menu to be aligned to the right side just like the image.
<div id="panel" style="position:fixed">
<panel-entry 1>
<panel-entry 2>
<panel-entry n>
<div id="settings" style="float:right/snapped to the right side>
<img src=settings>
<ul>
<li>setting 1</li>
<li>setting 2</li>
<li>setting n</li>
</ul>
</div>
</div>
Any idea using jQuery very much appreciated, feel free to rearrange any html.
Aside from your example not being HTML, I would anyhow correct the conceptual approach. There is no jQuery required for such a task, which can be done entirely in CSS.
You want your
#panel
to first of all contain a<ul>
which will contain<li>
s, which will be your<panel-entry>
, those should be set asinline-block
.The
#settings
should be one of those, perhaps with a specialclass
orid
(we'll keep settings for now). You canposition: absolute
this toright: 0
, or have itfloat
. Don't use an image element for this, but rather use abackground-image
.Inside this element, you will have a submenu: i.e. another
<ul>
withdisplay: none
, aposition:absolute
,right: 0
andtop: X
, so that X doesn't overlap with your#panel
.Next, you want to make the element visible on
:hover
ofli#settings
.Here's a working demo
Basic HTML
Basic CSS
No jQuery necessary, just give your
#panel
a width:See DEMO.