css - html/css 菜单,子菜单显示在页面左侧

标签 css

我正在尝试创建一个下拉菜单。但是在悬停时,我的子菜单出现在页面的左上角。我不知道我做错了什么。请帮忙。

这是 HTML:

<div id="modernbricksmenu2">
  <ul>
     <li id="current" style="margin-left: 0px"><a href="index.html">Home</a></li>
     <li><a href="aboutus.html">About Coborn </a></li>
     <li ><a href="services.html">Coborn Services</a>
           <ul>
                 <li><a href="services.html">Sumbuusa Ewooma</a></li>
                 <li><a href="services.html">Sumbuusa Ewooma</a></li>
                 <li><a href="services.html">Sumbuusa Ewooma</a></li>
           </ul>
     </li>


     <li><a href="careers.html">Cobon Careers</a></li>  
     <li><a href="training.html">Training</a></li>  

     <li><a href="contactus.html">Contact Us</a></li>   
     </ul>
     </div>

这是 CSS:

  #modernbricksmenu2{
   padding: 0;
   width: 100%;
    border-top: 5px solid #D25A0B; /*Brown color theme*/ 
   background: transparent;
   voice-family: "\"}\"";
    voice-family: inherit;
    }

   #modernbricksmenu2 ul{
   margin:0;
   margin-left: 0px; /*margin between first menu item and left browser edge*/
   padding: 0;
   list-style: none;


   }

   #modernbricksmenu2 li{
   display: inline;
    margin: 0 0px 0 0;
    padding: 0;
   text-transform:uppercase;
    position:relative;
    }


  #modernbricksmenu2 a{
  float: left;
  display: block;
   font: bold 11px Arial;
  color: white;
  text-decoration: none;
  margin: 0 1px 0 0; /*Margin between each menu item*/
   padding: 5px 10px;
  background-color: black; /*Brown color theme*/ 
  border-top: 1px solid white;
  }
  #modernbricksmenu2 a:hover{
  background-color: #D25A0B; /*Brown color theme*/ 
  color: white;
  }
  #modernbricksmenu2 ul ul{
  display:none;
  position:absolute;

  }

  #modernbricksmenu2 ul ul li{
  display:none;
   position: relative;
  float:none;

  }

  #modernbricksmenu2 ul li:hover > ul{
  margin:0px;
  padding:0px;
  display:block;
  }

  #modernbricksmenu2 ul li:hover > ul li{
  float:none;
   display:block;

    }

   #modernbricksmenu2 ul li:hover > ul li a{
   color:#336699;
   min-width:150px;
   }

  #modernbricksmenu2 ul li:hover > ul li a:hover{
  color:#fff;


  }

   #modernbricksmenu2 #current a{ /*currently selected tab*/
   background-color: #D25A0B; /*Brown color theme*/ 
   color: white;
   border-color: #D25A0B; /*Brown color theme*/ 
   }

另见此处:JsFiddle

最佳答案

它还影响了 Chrome。 试试这个它应该工作:jsfiddle

#modernbricksmenu2 a{
    display: inline-block;
    font: bold 11px Arial;
    color: white;
    text-decoration: none;
    margin: 0; /*Margin between each menu item*/
    padding: 5px 10px;
    background-color: black; /*Brown color theme*/ 
    border-top: 1px solid white;
}

关于css - html/css 菜单,子菜单显示在页面左侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19605800/

相关文章:

html - Div 没有响应 [基础]

html - 如何通过透明导航栏使横幅图片可见?

CSS 网格、ng-repeat 和未知数据

html - 图标字体 : use bigger font-size (inline-element) without affecting line-height

javascript - 我可以打开一个未选择默认选项卡的新窗口(网页)吗

javascript - 从 JavaScript 设置带有引号和逗号的 CSS 变量

php - 如何在包含的菜单的事件页面上设置背景?

html - 在 css 中围绕文本制作一个完美的正方形 bg?

HTML/CSS @媒体

html - 如何在一行中显示两个div