css - 在 Joomla 3.1 中仅使用 CSS 创建下拉菜单

标签 css drop-down-menu joomla joomla3.1

如果可能,我正在尝试仅使用 CSS 为我的自定义模板创建一个下拉菜单。

到目前为止,我已经创建了两个相互独立的菜单,主菜单和我想“下拉”的菜单。

这是我的 CSS 代码:

#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 是我想要下拉的菜单,它与主菜单在同一个 div 中。

当我看这个时,我只能看到主菜单,当我将鼠标悬停在主菜单上时,“sub1-info”菜单不会出现。我已经使用几乎完全相同的代码完成了此的纯 HTML/CSS 版本(即不使用 Joomla),并且运行良好。

我也曾尝试将“sub1-info”菜单设为主菜单的子菜单,结果是所有内容都重新排列并且 sub1 菜单中的链接不起作用,即使我已将菜单项链接到一篇文章。

最佳答案

您应该在此处查看 JED(Jooomla 扩展目录)上的第三方扩展:

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

您可以在 joomla 网站上安装许多现成的下拉菜单。

或者试试这个 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;
}

关于css - 在 Joomla 3.1 中仅使用 CSS 创建下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20613856/

相关文章:

css - 乔姆拉/FTP : Files updated via ftp won't update in browser

CSS 属性溢出 :hidden causes inner divs to appear below main div

html - 为什么 zurb ink 在 td 上添加额外的填充

javascript - 在父 div 之后查找 css 类

php - 过滤表 WHERE 1 列 = 来自另一个表的列

mysql - 从 MySql 导出到 sql 文件时如何自动转义内容中的引号?

html - Ionic - 如何将 ionic 列表变成网格

asp.net - "DropDownList.SelectedIndex = -1"问题

javascript - 卡斯珀JS : Selecting an option in dropdown menu made of <div> and dynamic classes

html - 发布后如何在所有文章中添加链接