Question

I am trying to create a drop-down menu for my custom template using just CSS if possible.

So far I have created two menus separate of each other, the main menu and the one I want to "drop down".

Here is my CSS code:

#sub1-info li
{
  display: none;
}

ul#main-menu li:hover div#sub1-info
{
   display: block;
}

ul#main-menu:hover +div#sub1-info
{
    display: block;
}

Sub1-info is the menu I want dropping down and is in the same div as the main menu.

When I look at this I can only see the main menu, the "sub1-info" menu does not appear when I hover over the main menu. I have done a pure HTML/CSS version of this (i.e. not using Joomla) using almost the exact same code and it worked out fine.

I have also tried making the "sub1-info" menu a child of the main menu, what happens is that everything gets rearranged and the Links in the sub1 menu don't work, even though I have linked the menu item to an article.

Was it helpful?

Solution

You should take a look at third party extensions on the JED (Jooomla Extension Directory) here :

http://extensions.joomla.org/extensions/structure-a-navigation/menu-systems/drop-a-tab-menus

There are many ready made dropdown menus you can install to you joomla website.

Or try this css :

body
{
    background-color: #CCC;
}
#container{
        width: 723px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 30px;
    position:relative;
}
div#header{
    height:249px;
}

div#main-menu
{
    width:100%;
    text-align: center;
  text-decoration: none;
  position:absolute;
  top:158px;
  left:0;

}
#main-menu ul{

}
#main-menu li
{
  display:inline-block;
  padding: 25px;
  list-style-type:none;
    color: #2ec315;
  font-family: sans-serif;
  text-decoration: none;
  font-size: larger;
}
#sub1-info{
    display:none;
}
#main-menu li ul
{
  display: none;
  position:absolute;
  width:100%;
  padding:10px 0;
  margin:0;
  left:0;
  background:#140d9b;
}
#main-menu li:hover ul{
    display:block
}

ul#main-menu li:hover div#sub1-info
{
   display: block;
}

ul#main-menu:hover +div#sub1-info
{
    display: block;
}

div#body
{
    width: 723px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 1px;
    height: auto;
    background-color: #140d9b;
    color: white;
    font-family: "Lucida Sans Unicode";
    text-align: justify;
}

.cat-children
{
  margin-left: 20px;
    outline:1px solid white;
  max-width: 180px;
  padding-left: 3px;
  padding-right: 3px;
}

div#footer
{
    width: 723px;
    margin-left: auto;
    margin-right: auto;
  margin-top: -18px;
}

h1
{
  font-family: "Lucida Sans";
    font-weight: bold;
    text-align: center;
}

p
{
    margin-left: 60px;
    margin-right: 50px;
    font-family: "Lucida Sans Unicode";
    text-align: justify;
}

a
{text-decoration: none;
color: #2ec315;}

a:hover
{color: white;}

.edit-icon
{
  display: none;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top