Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HR tag giving me fits 2

Status
Not open for further replies.

Einstein47

Programmer
Nov 29, 2001
737
0
0
US
Ok, take a look at this screen shot:
menu_bad.png

I am trying to create menus for navigation (my test site is here: Menu Frames. (Click on the "Find Case" button to see this same page in action). I have got most things worked out for IE (I broke something in FireFox, and I haven't figured out exactly what).

From the image the css for all the menu DIVs is identical - the issue is that the floating DIV (the one at the top right) hangs over the border - I don't want that. It isn't doing that on the test DIVs that I have that are just on the page. What could be causing this? Also, it only happens on the menus where there is an HR tag just before the last menu item.

Here is the CSS code:
Code:
/* careMenu.css */
#menuDiv ul {
	margin:0;
	padding:0;
	list-style-type:none;
	width:210px;
	border-width: 3px;
	border-style: outset;
	border-color: #fcfcfc;
	background-color:#eee;
}
#menuDiv ul li {
	position: relative;
	background:#eee;
	overflow:visible;
}
#menuDiv ul li ul {
	position: absolute;
	width: 190px;
	top: 0;
	visibility: hidden;
	background: #eee;
}
#menuDiv ul li a {
	font-family: Arial;
	font-size: 8pt;
	display: block;
	overflow: auto;
	padding: 2px 4px 2px 8px;
	margin: 0 1px;
	color: black;
	background-color: #eee;
	text-decoration: none;
}
#menuDiv a:hover {
	color: white;
	background-color: Highlight; 
/*	background-color: #b5e9ff;  */
}
#menuDiv hr {
	height:1px;
	display:block;
	margin: 0 !important;
	margin: -6px 0;
	color: #a8a8a8;
	background-color:#798c7c;
	border:0px;
}
#menuDiv .subfolderstyle {
	padding-right: 0;
	background: url(ArrowPopup.gif) no-repeat center right;
}
/* Holly Hack for IE \*/
* html #menuDiv ul li { float: left; height: 1%; }
* html #menuDiv ul li a { height: 1%; }
/* End of Holly Hack */

And why is it "Holly Hack" - shouldn't it be "Holy Hack"? Just a question.

Here is the HTML and JavaScript:
Code:
<script type="text/javascript">
[teal]/* This function will shrink the width of the given DIV until it can no longer
   shrink, or until the height gets larger and then it will increase the size
   slightly. */[/teal]
[b]function [red]resizeMenu[/red](menuDivObj)[/b] {
[teal]// When submenus have no spaces, the width can only be reduced so far[/teal]
	var origHeight = menuDivObj.offsetHeight;
	var prevWidth = 0;
	var delta = 0;
	while (origHeight == menuDivObj.offsetHeight
				&& menuDivObj.offsetWidth != prevWidth) {
		prevWidth = menuDivObj.offsetWidth;
		delta = Math.ceil(menuDivObj.offsetWidth * 0.12);
		menuDivObj.style.width = (menuDivObj.offsetWidth-delta)+"px";
	}
	(delta<12) ? delta=2 : delta=Math.floor(delta/4);
	while (origHeight != menuDivObj.offsetHeight) {
		menuDivObj.style.width = (menuDivObj.offsetWidth+delta)+"px";
	}
	menuDivObj.style.width = (menuDivObj.offsetWidth+5)+"px";
}
[teal]
//SuckerTree Vertical Menu 1.1 (Nov 8th, 06)
//By Dynamic Drive: [URL unfurl="true"]http://www.dynamicdrive.com/style/[/URL]
[/teal]
var menuids=["suckertree0","suckertree1"]
[teal]//Enter id(s) of SuckerTree UL menus, separated by commas[/teal]

[b]function [red]buildsubmenus[/red]()[/b] {
  for (var i=0; i<menuids.length; i++){
    var menuObj = document.getElementById(menuids[i]);
    resizeMenu(menuObj);
	var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		resizeMenu(ultags[t]);
		ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
		if (ultags[t].parentNode.parentNode.id==menuids[i]) {
[teal]			//if this is a first level submenu[/teal]
			ultags[t].style.left=(ultags[t].parentNode.offsetWidth)+"px"
[teal]			//dynamically position first level submenus to be width of main menu item[/teal]
		}
		else { [teal]//else if this is a sub level submenu (ul)[/teal]
[teal]			//position menu to the right of menu item that activated it[/teal]
			ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px"
		}
		ultags[t].parentNode.onmouseover=function(){
			this.getElementsByTagName("ul")[0].style.display="block"
			this.style.backgroundColor = "Highlight";
			this.getElementsByTagName("a")[0].style.color = "white";
			this.getElementsByTagName("a")[0].style.backgroundImage = "url(ArrowPopupSel.gif)";
		}
		ultags[t].parentNode.onmouseout=function(){
			this.getElementsByTagName("ul")[0].style.display="none"
			this.style.backgroundColor = "#eee";
			this.getElementsByTagName("a")[0].style.color = "black";
			this.getElementsByTagName("a")[0].style.backgroundImage = "url(ArrowPopup.gif)";
		}
	}
	for (var t=ultags.length-1; t>-1; t--){
[teal]		//loop through all sub menus again, and use "display:none" to hide menus
		//(to prevent possible page scrollbars[/teal]
		ultags[t].style.visibility="visible"
		ultags[t].style.display="none"
	}
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)

</script>

....

<div id="menuDiv">
<ul id="suckertree0">
<li><a href="#">Location Information</a>
<ul>
<li><a href="javascript: void window.top.goMenu('LocationAssignmentHistory');">Location Assignment History</a></li>
<li><a href="javascript: void window.top.goMenu('LocationCaseLoad');">Location Case Load</a></li>
</ul></li>
<li><a href="#">Staff Information</a>
<ul>
<li><a href="javascript: void window.top.goMenu('StaffCaseLoad');">Staff Case Load</a></li>
<li><a href="javascript: void window.top.goMenu('StaffAssignmentHistory');">Staff Assignment History</a></li>
</ul></li>
<li><a href="javascript: void window.top.goMenu('AdmissionReasonList');">Assignment Maintenance</a></li>
</ul>

<p>
<ul id="suckertree1">
<li><a href="#">Location Information</a>
<ul>
<li><a href="javascript: void window.top.goMenu('LocationAssignmentHistory');">Location Assignment History</a></li>
<li><a href="javascript: void window.top.goMenu('LocationCaseLoad');">Location Case Load</a></li>
</ul></li>
<hr>
<li><a href="#">Staff Information</a>
<ul>
<li><a href="javascript: void window.top.goMenu('StaffCaseLoad');">Staff Case Load</a></li>
<li><a href="javascript: void window.top.goMenu('StaffAssignmentHistory');">Staff Assignment History</a></li>
</ul></li>
<hr>
<li><a href="javascript: void window.top.goMenu('AdmissionReasonList');">Assignment Maintenance</a></li>
</ul>
</div>



Einstein47
There are no kangaroos in Austria!
[&#91;]Starbase47.com]
 
Validate your HTML first. I think that's your problem [smile] a nice easy one (I hope).

Oh... it's named the Holly hack after the discoverer/reporter person... Holly Bergevin.

Cheers,
Jeff



[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
If you must put a <hr> into a <ul>, it's got to be inside one of the <li>s to be valid - the only element that can be a child of <ul> is <li> (you can put what you like into the <li>s). This may or may not be the cause of your problem.

But why use a <hr> at all? Why not just give the <li> a bottom border?

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thanks guys - I'll try your suggestions and get back to you.

Einstein47
There are no kangaroos in Austria!
[&#91;]Starbase47.com]
 
Way to be Chris - just putting the <HR> in the <LI> container worked like a charm - I should have realized that I need to make my code validate first.

So I give a star to you too Jeff Baby for helping me see the light (and learn about Holly Bergevin). Man I love Tek-tips when people share!

(Maybe it it wrong to give multiple people stars - but you both helped me)

Einstein47
There are no kangaroos in Austria!
[&#91;]Starbase47.com]
 
Maybe it it wrong to give multiple people stars - but you both helped me
Not at all. You can award as many "thank you" stars as you like (but just one per person per thread). Good to see it was such a quick fix!

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top