• 0

Help with dHTML/CSS Menu Aligning + Sizing


Question

Take a look at the animation below. It shows what I have now and is a dHTML menu:

post-15711-1244768085.gif

As you can see, it uses the full span of the browser.

The sub menus are all of fixed lengths (that's why Sub menu 2.3 wraps).

And the sub menus position themselves from the left end of the parent menu.

However, below is a mock up of what I want:

post-15711-1244768116.gif

As you can see, the menu is now right aligned and doesn't use the fullness of the browser window.

The sub menus all have a MINIMUM width.

The sub menu also expands when the menu label is longer (e.g. Sub menu 2.3).

And the sub menu also positions itself from the right of it's parent.

How do I do this? I've included the code for the first example here:

dHTML_Menu.zipFetching info...

I'd really appreciate your help. Thank you.

Recommended Posts

  • 0

Not sure how you would do it in a DHTML menu or it makes a difference being dhtml. But in html one would set it up as an unordered list and float ul tag to the right and li tag to the left. That way the element would take up the width they need. Padding can be used to provide the text some breathing space. Hope this helps.

  • 0
  TonyLock said:
It is a CSS menu, what do you think the "d" stands for in "dHTML"?

...

DHTML = JavaScript + HTML (and maybe CSS)

That your menu does nothing at all if JS is disabled means it isn't using CSS for the actual display, it's using JavaScript.

Anyway, the problem is this bit of CSS you have in the ".jqueryslidemenu" selector

width: 100%;

Replace that with "float:right;"

  • 0

I took a quick look at the code, I think this is what you mean:

<div style="width:100%">
<div style="right:0px;width:350px;position:absolute">


<div id="myslidemenu" class="jqueryslidemenu">
<ul id="nav">
	<li><a href="#">Menu 1</a>
		<ul>
			<li><a href="#">Sub Menu 1.1</a></li>
			<li><a href="#">Sub Menu 1.2</a></li>
		</ul>
	</li>
	<li><a href="#">Menu 2</a>
		<ul>
			<li><a href="#">Sub Menu 2.1</a></li>
			<li><a href="#">Sub Menu 2.2</a></li>
			<li><a href="#">This is a very long sub menu label 2.3</a></li>
		</ul>
	</li>
	<li><a href="#">Long Menu Label 3</a>
		<ul>
			<li><a href="#">Sub Menu 3.1</a></li>
			<li><a href="#">Sub Menu 3.2</a></li>
			<li><a href="#">Sub Menu 3.3</a></li>
		</ul>
	</li>
</ul>
<br style="clear: left" />
</div>


</div>
</div>

Put the #myslidemenu div inside a div telling it to stay right of the div with width of 100%.

Edit: you'll have to tune it yourself, thats just a rough edit.

  • 0

Yeah, I used chrome when i was editing it, as for ie... i'll check it now...

Edit: Works perfect in IE8, is left aligned in IE7 and left aligned with padding on the third menu in IE6, maybe you could ad an alternate stylesheet for IE6 and IE7.

  • 0

Done. works perfectly with chrome, IE8 & safari, minor bug in IE7 with longer sub menu titles, extra padding below sub menu options in IE6. Overall animation works much better with right alignment than old menu.

Dropdown_Menu_2.zipFetching info...

  • 0

OK, here's a Question, how do I dynamically add the down arrow ("▼" or rather "▼") to the top menus?

Here was what I was using in the past... but I don't know where to add the code in to your new script

$(this).children("a:eq(0)").append('<span>▼</span>')

  • 0

The down arrow I put in is from the character map, its just a letter, in the one used in the other menu was a picture, When you say dynamically you mean it only shows when its active? If so you can put in the picture from the other one in and you should be able to control it in the css.

  • 0

Right, made some small changes, it now looks slightly better in IE7 and the arrow changes direction when active. You might want to adjust them. You can easily change the images to do this.

Dropdown_Menu_2.1.zipFetching info...

Edited by Gally
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Oh no... here we go again. Tha same sh*t that happaned to Mail & Calendar...
    • I too have worked with pro gear for decades and so I found the interface to be unintuitive from both the pro and casual side (a rare "accomplishment" by what are obviously otherwise skilled coders, hehe). I eventually got it to work, thanks for offering, but I found other compatibility issues with my own use case, so I just dropped it entirely. Right now, I just use an analog line out/line in approach which works as expected across all usage scenarios. With both machines on the same power block/outlet, I'm not getting any analog hum or hiss. My next step will be to try the updated Multiplicity 4 when a bug, addressing this very issue unfortunately, is resolved. Knowing Stardock, that could be tomorrow or five years from now, so I check back every few months to see it it's fixed and I want to upgrade. Again, thanks for offering to help.
    • We recognize that performance can use some improvements, and we continue to work on improving it. However, it's worth noting that massive performance improvements don't happen overnight, they take a lot of work and effort, and in most cases, the improvements are more noticeable when you compare across several updates. That said, Files is open-source and everyone is invited to help with these efforts 🙂
    • A lot of effort has gone into improving stability and Files Preview now has a 99% crash free rate. These improvements will make their way to Files Stable when v4 is released later this year. If you're still experiencing issues, please report them on GitHub or Discord so we can track them properly.
  • Recent Achievements

    • Rookie
      Snake Doc went up a rank
      Rookie
    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      495
    2. 2
      Michael Scrip
      203
    3. 3
      ATLien_0
      197
    4. 4
      Xenon
      137
    5. 5
      +FloatingFatMan
      115
  • Tell a friend

    Love Neowin? Tell a friend!