webForumDet fria alternativet

Göra om meny

3 svar · 463 visningar · startad av Asa

AsaMedlem sedan dec. 20011 860 inlägg
#1

Hur gör man om denna menyn:
http://www.alistapart.com/d/horizdropdowns/horizontal2.htm

så den ligger så som denna menyn:
http://www.dhtmlcentral.com/projects/coolmenus/examples/menu1.html

meny.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Horizontal Drop Down Menus</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="drop_down.js"></script>
<style type="text/css">
@import "style3.css";
</style>
</head>
<body> 
<ul id="nav"> 
  <li><a href="#">Home</a></li> 
  <li><a href="#">About</a> 
    <ul> 
      <li><a href="#">History</a></li> 
      <li><a href="#">Team</a></li> 
      <li><a href="#">Offices</a></li> 
    </ul> 
  </li> 
  <li><a href="#">Services</a> 
    <ul> 
      <li><a href="#">Web Design</a></li> 
      <li><a href="#">Internet Marketing</a></li> 
      <li><a href="#">Hosting</a></li> 
      <li><a href="#">Domain Names</a></li> 
      <li><a href="#">Broadband</a></li> 
    </ul> 
  </li> 
  <li><a href="#">Contact Us</a> 
    <ul> 
      <li><a href="#">United Kingdom</a></li> 
      <li><a href="#">France</a></li> 
      <li><a href="#">USA</a></li> 
      <li><a href="#">Australia</a></li> 
    </ul> 
  </li> 

</ul> 
</body>
</html>

drop_down.js

// JavaScript Document

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;

style3.css

body {
	font: normal 11px verdana;
	}

ul {
	margin: 0;
	padding: 0;
	list-style: none;
	width: 150px; /* Width of Menu Items */
	border-bottom: 1px solid #ccc;
	}
	
ul li {
	position: relative;
	}
	
li ul {
	position: absolute;
	left: 149px; /* Set 1px less than menu width */
	top: 0;
	display: none;
	}

/* Styles for Menu Items */
ul li a {
	display: block;
	text-decoration: none;
	color: #777;
	background: #fff; /* IE6 Bug */
	padding: 5px;
	border: 1px solid #ccc; /* IE6 Bug */
	border-bottom: 0;
	}
	
/* Holly Hack. IE Requirement \*/
* html ul li { float: left; height: 1%; }
* html ul li a { height: 1%; }
/* End */

li:hover ul, li.over ul { display: block; } /* The magic */
bossseMedlem sedan juni 2003772 inlägg
#2

Inte svar på din fråga, men ett horizontellt liknande det du efterfrågade.

<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script type="text/javascript">
<!--
window.onload=visa;
function visa(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}
//-->
</script>
<style type="text/css">
body {margin: 0;padding: 0;background: white;font:80% verdana, arial,sans-serif;}
dl, dt, dd, ul, li {margin: 0;padding: 0;list-style-type:none;}
#menu {position: absolute;top: 0;left: 0;z-index:100;width:100%;}
#menu dl {float: left;width: 12em;margin: 0 1px;}
#menu dt {cursor: pointer;text-align:center;font-weight:bold;background:#ccc;border:1px solid gray;}
#menu dd {border: 1px solid gray;}
#menu li {text-align: center;background:#fff;}
#menu li a, #menu dt a {color: #000;text-decoration: none;display:block;height:150%; block;border:0 none;}
#menu li a:hover, #menu dt a:hover {background: #eee;}
#site {position:absolute;z-index:1;top:70px;left:10px;color:#000;background-color:#ddd;padding:5px;border:1px solid gray}
a {text-decoration: none;color: black;color:#222;}
</style>
</head>
<body>
<div id="menu">
	<dl>			
	<dt onmouseover="javascript:visa('smenu1');">Menu 1</dt>
<dd id="smenu1">
		<ul>
	<li><a href="#">Sous-Menu 1.1</a></li>
	<li><a href="#">Sous-Menu 1.2</a></li>
	<li><a href="#">Sous-Menu 1.3</a></li>
	<li><a href="#">Sous-Menu 1.4</a></li>
	<li><a href="#">Sous-Menu 1.5</a></li>
	<li><a href="#">Sous-Menu 1.6</a></li>
		</ul>
</dd>
</dl>
<dl>	
	<dt onmouseover="javascript:visa('smenu2');">Menu 2</dt>
<dd id="smenu2">
		<ul>
	<li><a href="#">Sous-Menu 2.1</a></li>
	<li><a href="#">Sous-Menu 2.2</a></li>
	<li><a href="#">Sous-Menu 2.3</a></li>
	<li><a href="#">Sous-Menu 2.4</a></li>
		</ul>
</dd>
</dl>
<dl>	
	<dt onmouseover="javascript:visa('smenu3');">Menu 3</dt>
<dd id="smenu3">
		<ul>
	<li><a href="#">Sous-Menu 3.1</a></li>
	<li><a href="#">Sous-Menu 3.2</a></li>
	<li><a href="#">Sous-Menu 3.3</a></li>
	<li><a href="#">Sous-Menu 3.4</a></li>
	<li><a href="#">Sous-Menu 3.5</a></li>
		</ul>
</dd>
</dl>
<dl>	
	<dt onmouseover="javascript:visa('smenu4');">Menu 4</dt>
<dd id="smenu4">
		<ul>
	<li><a href="#">Sous-Menu 4.1</a></li>
	<li><a href="#">Sous-Menu 4.2</a></li>
	<li><a href="#">Sous-Menu 4.3</a></li>
		</ul>
</dd>
</dl>
</div>
</body>
</html>
AsaMedlem sedan dec. 20011 860 inlägg
#3

Funkar den i alla webbläsare oxå?

bossseMedlem sedan juni 2003772 inlägg
#4

I alla vet jag inte!
Den funkar i vart fall i de två största IE och Firefox, troligen i ännu fler.

130 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
128 ms — hämta tråd, inlägg och bilagor (db)