Page 1 of 1

Css horizontal menu, submnenu not doing what I want.

Posted: Sat Mar 16, 2013 8:28 am
by Goofan
Hi,

I don't know if I need to work with php on this to get it to work. That is why I post it here.

What I want my script todo:

If you goto:
http://www.drang.se/Test/Index.php

You will find the very basic of my work atm. (Not much as of yet)

I want it so that if you go into -> Bilder -> 2012
the submenu of that should be positioned as it is with my -> 2011.

I get that the position is relative to the parent and that it is positioning it self according to the "2012" selection.

Is there a way for me to change this?

Code /Basic*

Index.php

Code: Select all


<!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>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="res/Style.css" rel="stylesheet" type="text/css">
        <link href="SpryAssets/Menu.css" rel="stylesheet" type="text/css" />
        <title>Drängens Allservice - Fixar Allt</title>
        <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    </head>
    
    <body>
    <?php
	// Dim
	//Ladda Antalet år genom algorithmer
	
	$pictureYear = array (
			"2011", "2012", "2013"); // Alla Åren
	$pictureMonth = array(
			"Jan", "Feb", "Mars", "April", "Maj", "Juni", "Juli", "Aug", "Sept", "Okt", "Nov", "Dec");  // Alla Månaderna
	?>
    <center>
            <!-- **********************************************
           					 Horizontal Menu
                                  START
             **************************************************-->
            <div style="clear:both;"></div> <!-- Kollapsar  -->
            <div class="header">
            	<img src="res/Banner.png" height="150" width="768"/>
            </div>
      <div class="wrap"> <!-- Klassen används inte -->
        <ul id="MenuBar1" class="MenuBarHorizontal">
                            <li><a href="Index.php">Drängen</a></li>
                            <li><a class="MenuBarItemSubmenu" href="#">Tjänster</a>
                                <ul>
                                    <li><a class="MenuBarItemSubmenu" href="#">Gräva</a>
                                        <ul>
                                            <li><a href="Index.php?page=work1">Schaktning</a></li>
                                            <li><a href="Index.php?page=work2">Dranering</a></li>
                                        </ul>
                                    </li>
                                    <li><a href="Index.php?page=other">Annat</a></li>
                                </ul>
                            </li>
                            <li><a class="MenuBarItemSubmenu" href="#Pictures">Bilder</a>
                                <ul>
                                	<?php
										for ($y = 0; $y < Count($pictureYear); $y++){
											echo "<li><a class='MenuBarItemSubmenu' href='#$pictureYear[$y] '>".$pictureYear[$y] ."</a>";
												echo "<ul>";
													$numStart = 0;
													if ($pictureYear[$y] == "2011"){ $numStart = 5;	}//Set at 5 because buisness started on june.
													for ($m = $numStart; $m < Count($pictureMonth); $m++){
														echo "<li> <a href='Index.php?year=$pictureYear[$y]&month=$pictureMonth[$m]'>
														" .$pictureMonth[$m]."
														</a></li>";	
													}
												echo "</ul>";
											echo "</li>";
										}
									?>
                                </ul>
                            </li>
                          <li><a href="Index.php?page=Contact">Kontakta oss</a></li>
                    </ul>
        </div>
                <!-- **********************************************
           					 Horizontal Menu
                                   END
             **************************************************-->
      <script type="text/javascript">
		  var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:
		  "SpryAssets/SpryMenuBarRightHover.gif"});
	  </script>
      <div style="clear:both;"></div> <!-- Kollapsar  -->
            <div class="main">
            <hr />
              <p>Hej hej</p>
            </div>
      <div class="footer">
      </div>
        </center>
    </body>
</html>
Style.css

Code: Select all


.header{
}
.main{
	background-color:#EEE;
	margin: 0;
	padding: 0;
	position: relative;
	Width:1000px;
	height:500px;
	
	border-bottom: 1px solid rgb(204,204,204);
	border-left: 1px solid rgb(204,204,204);
	border-right: 1px solid rgb(204,204,204);
	overflow:auto;
	
	text-align:left;
}
.wrap{
	left: 25%;
	Width:1000px;
	height:37px;
	
	border-top: 1px solid rgb(204,204,204);
	border-left: 1px solid rgb(204,204,204);
	border-right: 1px solid rgb(204,204,204);
}
.footer{
}
p{
padding-top:5px;
padding-bottom:15px;
padding-right:25px;
padding-left:25px;
}
Menu.css

Code: Select all

@charset "UTF-8";

/*******************************************************************************

 LAYOUT: width, height, font, margin ...

 *******************************************************************************/

/* The outermost container of the Menu Bar, an auto width box with no margin or padding */
ul.MenuBarHorizontal{
	margin: 0 0 0 0;
	padding: 0;
	list-style-type: none;
	font-size: 100%;
	cursor: default;
	width: auto;
	float:left;
}

/* Set the active Menu Bar with this class, currently setting z-index to accomodate IE rendering bug: http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html */
ul.MenuBarActive{
	z-index: 1000;
}
/* Menu item containers, position children relative to this container and are a fixed width */
ul.MenuBarHorizontal li{ /*Menyn Parent */
	margin: 0;
	padding: 0;
	list-style-type: none;
	font-size: 100%;
	position: relative;
	text-align: center;
	cursor: pointer;
	width: 250px; /* Width of Parental Menu Bar. */
	float: left; /* Making the menu bar Horizontal*/
}
/* Submenus should appear below their parent (top: 0) with a higher z-index, but they are initially off the left side of the screen (-1000em) */
ul.MenuBarHorizontal ul{ /*Menyn Parent-child */
	margin: 0;
	padding: 0;
	list-style-type: none;
	font-size: 100%;
	z-index: 1020;
	cursor: default;
	width: 123.5px;
	position: absolute;
	left: -1000em;
}

/* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to auto so it comes onto the screen below its parent menu item */
ul.MenuBarHorizontal ul.MenuBarSubmenuVisible{
	left: auto;
}
/* Menu item containers are same fixed width as parent */
ul.MenuBarHorizontal ul li{
	width: 123.5px;
	height:100%;
}
/* Submenus should appear slightly overlapping to the right (100%) and up (-1%) */
ul.MenuBarHorizontal ul ul{
	position: absolute;
	margin: -1% 0 0 100%;
}
/* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to 0 so it comes onto the screen */
ul.MenuBarHorizontal ul.MenuBarSubmenuVisible ul.MenuBarSubmenuVisible{
	left: auto;
	top: 0;
}

/*******************************************************************************

 DESIGN: color scheme, borders, fonts

 *******************************************************************************/

/* Submenu containers have borders on all sides */
ul.MenuBarHorizontal ul{
	border: 0.5px solid #CCC;
}
/* Menu items are a light gray block with padding and no text decoration */
ul.MenuBarHorizontal a{
	display: block;
	cursor: pointer;
	background-color: #EEE; /* COLOR OF THE MENU BAR!*/
	padding: 0.5em 0.75em;
	color: #333;
	text-decoration: none;
}
/* Menu items that have mouse over or focus have a blue background and white text */
ul.MenuBarHorizontal a:hover, ul.MenuBarHorizontal a:focus{
	background-color: #666;
	color: #FFF;
}
/* Menu items that are open with submenus are set to MenuBarItemHover with a blue background and white text */
ul.MenuBarHorizontal a.MenuBarItemHover, ul.MenuBarHorizontal a.MenuBarItemSubmenuHover, ul.MenuBarHorizontal a.MenuBarSubmenuVisible{
	background-color: #666;
	color: #FFF;
}

/*******************************************************************************

 SUBMENU INDICATION: styles if there is a submenu under a given menu item

 *******************************************************************************/

/* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
ul.MenuBarHorizontal a.MenuBarItemSubmenu{
	background-image: url(SpryMenuBarDown.gif);
	background-repeat: no-repeat;
	background-position: 95% 50%;
}
/* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
ul.MenuBarHorizontal ul a.MenuBarItemSubmenu{
	background-image: url(SpryMenuBarRight.gif);
	background-repeat: no-repeat;
	background-position: 95% 50%;
}
/* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
ul.MenuBarHorizontal a.MenuBarItemSubmenuHover{
	background-image: url(SpryMenuBarDownHover.gif);
	background-repeat: no-repeat;
	background-position: 95% 50%;
}
/* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
ul.MenuBarHorizontal ul a.MenuBarItemSubmenuHover{
	background-image: url(SpryMenuBarRightHover.gif);
	background-repeat: no-repeat;
	background-position: 95% 50%;
}

/*******************************************************************************

 BROWSER HACKS: the hacks below should not be changed unless you are an expert

 *******************************************************************************/

/* HACK FOR IE: to make sure the sub menus show above form controls, we underlay each submenu with an iframe */
ul.MenuBarHorizontal iframe{
	position: absolute;
	z-index: 1010;
	filter:alpha(opacity:0.1);
}
/* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */
@media screen, projection
{
	ul.MenuBarHorizontal li.MenuBarItemIE{
		display: inline;
		f\loat: left;
		background: #FFF;
	}
}
I also go a javascript script but I don't see how it should effect this at it only determines the browser used and the time delayed as showing/hiding the submenus.

Thanks in advance!

Regards,
Thomas

Re: Css horizontal menu, submnenu not doing what I want.

Posted: Wed Apr 10, 2013 10:11 am
by Jade
I don't see any sub-menus for 2011 or 2012 so I can't help you if I can't see what's happening.