[GELÖST]CSS Menu horizontal, | einfügen und hover effekt

Für Fragen und Diskussionen zum Layout und Design, Templates und Stylesheets sowie Themes
Post Reply
new.matreix
Forum Members
Forum Members
Posts: 22
Joined: Tue Mar 18, 2008 10:39 am

[GELÖST]CSS Menu horizontal, | einfügen und hover effekt

Post by new.matreix »

Hallo zusammen

Das Menu klappt eigentlich soweit, nur möchte ich einen seperator zwischen den Menüpunkten und das aber auch nur in der ersten Ebene haben. Leider krieg ich das nicht hin. Ich verwende das template css menu:

Code: Select all

{* CSS classes used in this template:
#menuwrapper - The id for the <div> that the menu is wrapped in. Sets the width, background etc. for the menu.
#primary-nav - The id for the <ul>
.menuparent - The class for each <li> that has children.
.menuactive - The class for each <li> that is active or is a parent (on any level) of a child that is active. *}
{if $count > 0}
<div id="menuwrapper">
<ul id="primary-nav">
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}

	{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}

	{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
	</li>
{elseif $node->index > 0}</li>
{/if}
{if $node->parent == true or ($node->current == true and $node->haschildren == true)}
	<li class="menuactive menuparent"><a class="menuactive menuparent" 
{elseif $node->current == true}
	<li class="menuactive"><a class="menuactive" 
{elseif $node->haschildren == true}
	<li class="menuparent"><a class="menuparent" 
{elseif $node->type == 'sectionheader'}
        <li class="sectionheader"><span> {$node->menutext} </span>
{elseif $node->type == 'separator'}
        <li style="list-style-type: none;"> <hr class="separator" />
{else}
	<li><a 
{/if}
{if $node->type != 'sectionheader' and $node->type != 'separator'}
href="{$node->url}" {if $node->accesskey != ''}accesskey="{$node->accesskey}" {/if}{if $node->tabindex != ''}tabindex="{$node->tabindex}" {/if}{if $node->titleattribute != ''}title="{$node->titleattribute}"{/if}{if $node->target ne ""} target="{$node->target}"{/if}><dfn>{$node->hierarchy}: </dfn>{$node->menutext}</a>
{elseif $node->type == 'sectionheader'}
><dfn>{$node->hierarchy}: </dfn>{$node->menutext}</a>
{/if}

{/foreach}

	{repeat string="</li></ul>" times=$node->depth-1}		</li>
	</ul>
<div class="clearb"></div>
</div>
{/if}

des weiteren funzt das rollover nicht. komischerweise aber bei den nicht links im Menu schon. Weiss jemand weshalb? Hier mein css:

Code: Select all

/*****************
browsers interpret margin and padding a little differently, 
we'll remove all default padding and margins and
set them later on
******************/
* {
margin:0;
padding:0;
}

/*
Set initial font styles
*/
body {
   text-align: left;
   font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
   font-size: 75.01%;
   line-height: 1em;
}

/*
set font size for all divs,
this overrides some body rules
*/
div {
   font-size: 1em;
}

/*
if img is inside "a" it would have 
borders, we don't want that
*/
img {
   border: 0;
}

/*
default link styles
*/
/* set all links to have underline and bluish color */
a,
a:link 
a:active {
   text-decoration: underline;
/* css validation will give a warning if color is set without background color. this will explicitly tell this element to inherit bg colour from parent element */
   background-color: inherit; 
   color: #96a619; 
}

a:visited {
   text-decoration: underline;
   background-color: inherit;
  color: #18507C;                /* a different color can be used for visited links */
}


/* remove underline on hover and change color */
a:hover {
   text-decoration: none;
   background-color: none;
   color: #96a619;
}

/*****************
basic layout 
*****************/
body {
   background-color: #a2daf4;
   color: #009ee0;
   margin:1em; /* gives some air for the pagewrapper */
}

/* center wrapper, min max width */
div#pagewrapper {
   border: 1px solid black;
   margin: 0 auto;     /* this centers wrapper */
   max-width: 80em; /* IE wont understand these, so we will use javascript magick */
   min-width: 60em;
   background-color: #fff;;
   color: #009ee0;
}


/*** header ***
we will hide text and replace it with a image
we need to assign a height for it
*/

div#header {
   height: 125px; /* adjust according your image size */
   background: #c3c77d;           
}

div#header h1 a {
/* you can set your own image here */
   background: #c3c77d url(images/cms/head.jpg) no-repeat 0 0px; 
   display: block; 
   height: 125px;             /* adjust according your image size */
   text-indent: -999em;  /* this hides the text */
   text-decoration:none; /* old firefox would have shown underline for the link, this explicitly hides it */
}

div#search {
   float: right;
   width: 23em;     /* enough width for the search input box */
   text-align: right;
   padding: 0.6em 0 0.2em 0;
   margin: 0 1em;
}

div.breadcrumbs {
   padding: 1em 0 1.2em 0; /* CSS short hand rule first value is top then right, bottom and left */
   font-size: 90%;             /* its good to set fontsizes to be relative, this way viewer can change his/her fontsize */
   margin: 0 1em;              /* css shorthand rule will be opened to be "0 1em 0 1em" */
   border-bottom: 1px dotted #000;
}

 div.breadcrumbs span.lastitem { 
   font-weight:bold; 
 } 

 ndiv#content {
   margin: 1.5em auto 2em 0; /* some air above and under menu and content */
}

div#spacer {
   height: 8em; /* some air above and under menu and content */
}

div#main {
   margin-left: 15%; /* this will give room for sidebar to be on the left side, make sure this space is bigger than sidebar width */
   margin-right: 15%; /* and some air on the right */
}


div#sidebar {
   float: left;  /* set sidebar on the left side. Change to right to float it right instead. */
   width: 26%;    /* sidebar width, if you change this please also change #main margins */
   display: inline;  /* FIX ie doublemargin bug */
   margin-left: 0;
}

/* if sidebar doesnt include menu but content add class="hascontent" */
div#sidebar.hascontent {
   padding: 0 1%;
   width: 24%;  /* make width smaller if there's padding, or it will get too wide for the floated divs in IE */
}

div#footer {
   clear:both;       /* keep footer below content and menu */
   color: #009ee0;
   background-color: #FFFFFF; /* same bg color as in header */
}

span.fseperator { color: #b5bb5d;font-size: 1.2em;font-weight: bold;}

div#footer p {
   font-size: 0.8em;
   padding: 1.5em;      /* some air for footer */
   text-align: center; /* centered text */
   margin:0;
}

div#footer p a {
   color: #fff; /* needed becouse footer link would be same color as background otherwise */
}

/* as we hid all hr for accessibility we create new hr with extra div element */
div.hr {
   height: 1px;
   margin: 1em;
   border-bottom: 1px dotted black;
}

/* relational links under content */
div.left49 {
  float: left;
  width: 49%;  /* 50% for both left and right might lead to rounding error on some browser */
}

div.right49 {
  float: right;
  width: 49%;
  text-align: right;
}




/********************
CONTENT STYLING
*********************/
div#content {

}

/* HEADINGS */
h1 {
   color: #009ee0; 
   font-size: 2em; 
   text-align: left; 
}
h2 {
   color: #009ee0; 
   font-size: 2em; 
   text-align: left; 
   padding-bottom: 1em;
}
h3 {
   color: #009ee0; 
   font-size: 1.5em; 
   text-align: left; 
}

/* HEADINGS */
div#content h1 {
   font-size: 3em;  /* font size for h1 */
   line-height: 1em;
   margin: 0;
}0095dd
div#content h2 {
   color: #009ee0; 
   font-size: 5em; 
   text-align: left; 
/* some air around the text */
   padding-left: 0.5em;
   padding-bottom: 1px;
/* set borders around header */
   line-height: 1.5em;
/* and some air under the border */
   margin: 0 0 0.5em 0;
}
div#content h3 {
   color: #009ee0; 
   font-size: 1.3em;
   line-height: 1.3em;
   margin: 0 0 0.5em 0;
}
div#content h4 {
   color: #009ee0; 
   font-size: 1.2em;
   line-height: 1.3em;
   margin: 0 0 0.25em 0;
}
div#content h5 {
   font-size: 1.1em;
   line-height: 1.3em;
   margin: 0 0 0.25em 0;
}
h6 {
   font-size: 1em;
   line-height: 1.3em;
   margin: 0 0 0.25em 0;
}
/* END HEADINGS */

/* TEXT */
p {
   font-size: 1em;
   margin: 0 0 1.5em 0;  /* some air around p elements */
   line-height:1.4em;
   padding: 0;
}
blockquote {
   border-left: 10px solid #ddd;
   margin-left: 10px;
}
pre {
   font-family: monospace;
   font-size: 1.0em;
}
strong, b {
/* explicit setting for these */
   font-weight: bold;
}
em, i {
/* explicit setting for these */
   font-style:italic;
}

/* Wrapping text in <code> tags. Makes CSS not validate */
code, pre {
 white-space: pre-wrap;       /* css-3 */
 white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
 white-space: -pre-wrap;      /* Opera 4-6 */
 white-space: -o-pre-wrap;    /* Opera 7 */
 word-wrap: break-word;       /* Internet Explorer 5.5+ */
 font-family: "Courier New", Courier, monospace;
 font-size: 1em;
}

pre {
   border: 1px solid #000;  /* black border for pre blocks */
   background-color: #ddd;
   margin: 0 1em 1em 1em;
   padding: 0.5em;
   line-height: 1.5em;
   font-size: 90%;   /* smaller font size, as these are usually not so important data */
}

/* END TEXT */

/* LISTS */
div#main ul,
div#main ol,
div#main dl {
  font-size: 1.0em;
   line-height:1.4em;
   margin: 0 0 1.5em 0;
}
div#main ul li,
div#main ol li {
   margin: 0 0 0.25em 3em;
}

div#dl dt {
   font-weight: bold;
   margin: 0 0 0.25em 3em;
}
div#dl dd {
   margin: 0 0 0 3em;
}
/* END LISTS */
Besten Dank für eure Hilfe!
Last edited by new.matreix on Thu Mar 20, 2008 10:47 am, edited 1 time in total.
cyberman

Re: CSS Menu horizontal, | einfügen und hover effekt

Post by cyberman »

new.matreix wrote: Das Menu klappt eigentlich soweit, nur möchte ich einen seperator zwischen den Menüpunkten und das aber auch nur in der ersten Ebene haben. Leider krieg ich das nicht hin.
Ein Separator ist ein Inhaltstyp, den du manuell zwischen den Ebenen einfügen kannst/musst.

Und dazu noch eine kleine Änderung des MM-Templates

Code: Select all

{elseif $node->type == 'separator'}
        <li style="list-style-type: none;"> |
NaN

Re: CSS Menu horizontal, | einfügen und hover effekt

Post by NaN »

Was genau meinst Du mit Seperator?
Es gibt einen Inhaltstyp "Seperator".
Dazu musst Du allerdings im Inhalt zwischen jeder Seite der 1. Ebene eine zusätzliche Seite von diesem Typ anlegen.
Welches Stylesheet benutzt Du.
Das vertikale oder das horizontale CSS Menü?

Einfacher wäre es, an folgender Stelle Deinen Sperator einzufügen:
new.matreix wrote:
{* CSS classes used in this template:
#menuwrapper - The id for the that the menu is wrapped in. Sets the width, background etc. for the menu.
#primary-nav - The id for the
.menuparent - The class for each that has children.
.menuactive - The class for each that is active or is a parent (on any level) of a child that is active. *}
{if $count > 0}


{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}

{repeat string="" times=$node->depth-$node->prevdepth}
{elseif $node->depth prevdepth}

{repeat string="" times=$node->prevdepth-$node->depth}

{elseif $node->index > 0}

    {if $node->depth==1}
          Hier muss der Separator für die 1.Ebene hin
          (Eine Möglichkeit wäre z.B.: |;
          Diese Klasse Muss dann natürlich noch via Stylesheet so formatiert werden, dass sie auch den gleichen Abstand hat, wie die Links in der 1.Ebene)
  {/if}


{/if}
{if $node->parent == true or ($node->current == true and $node->haschildren == true)}
current == true}
haschildren == true}
type == 'sectionheader'}
        {$node->menutext}
{elseif $node->type == 'separator'}
       
{else}
type != 'sectionheader' and $node->type != 'separator'}
href="{$node->url}" {if $node->accesskey != ''}accesskey="{$node->accesskey}" {/if}{if $node->tabindex != ''}tabindex="{$node->tabindex}" {/if}{if $node->titleattribute != ''}title="{$node->titleattribute}"{/if}{if $node->target ne ""} target="{$node->target}"{/if}>{$node->hierarchy}: {$node->menutext}
{elseif $node->type == 'sectionheader'}
>{$node->hierarchy}: {$node->menutext}
{/if}

{/foreach}

{repeat string="" times=$node->depth-1}



{/if}
new.matreix
Forum Members
Forum Members
Posts: 22
Joined: Tue Mar 18, 2008 10:39 am

Re: CSS Menu horizontal, | einfügen und hover effekt

Post by new.matreix »

Erstmals, vielen Dank euch beiden für eure Antworten!

Entschuldigung, bin ein CMS Made Simple Newbe und wusste nicht dass es Inhaltstypen gibt die Seperator heissen.

Eigentlich will ich nur eine sichtbare Abtrennung zwischen den einzelnen Menüpunkte (oberste ebene)

Also so:

Home | Über Uns | Kontakt| etc...

@ NaN
super nun hab ichs fast. nur kommt der Seperator nicht bei den Menus die Untermenus enthalten.

Und gleich noch eine zusätzliche Frage: Wie kann ich ein Bild (Pfeil) NUR bei den Untermenus jeweils auf der lin ken Seite einfügen?
NaN

Re: CSS Menu horizontal, | einfügen und hover effekt

Post by NaN »

new.matreix wrote:
super nun hab ichs fast. nur kommt der Seperator nicht bei den Menus die Untermenus enthalten.
Dann füg den Code für den "Separator" einfach eine Schleife weiter oben nochmal mal ein:

{* CSS classes used in this template:
#menuwrapper - The id for the that the menu is wrapped in. Sets the width, background etc. for the menu.
#primary-nav - The id for the
.menuparent - The class for each that has children.
.menuactive - The class for each that is active or is a parent (on any level) of a child that is active. *}
{if $count > 0}


{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}

  {repeat string="" times=$node->depth-$node->prevdepth}
{elseif $node->depth prevdepth}

  {repeat string="" times=$node->prevdepth-$node->depth}
 

    {if $node->depth==1}
          Hier muss der Separator für die 1.Ebene das erste mal hin.
  {/if}


{elseif $node->index > 0}

    {if $node->depth==1}
          Hier muss der Separator für die 1.Ebene das zweite mal hin.
  {/if}


{/if}
...
new.matreix wrote:
Wie kann ich ein Bild (Pfeil) NUR bei den Untermenus jeweils auf der lin ken Seite einfügen?
Das kannst Du relativ einfach via CSS machen. Schau Dir einfach mal Quelltext der HTML-Ausgabe im Browser an. Das Menü wird dort so aufgebaut:


    Link in der ersten Ebene
         
                Link in der zweiten Ebene
         
   
    Dein Seperator
    ...


Demnach musst Du im Stylesheet für das CSS-Menü nach #primary-nav li ul li bzw. #pimary-nav li ul li a suchen. Da kannst Du dann ein Hintergrundbild definieren.
new.matreix
Forum Members
Forum Members
Posts: 22
Joined: Tue Mar 18, 2008 10:39 am

Re: CSS Menu horizontal, | einfügen und hover effekt

Post by new.matreix »

Besten Dank habs hinbekommen!!!
Post Reply

Return to “Layout und Design”