我正在嘗試創建3個輪胎的下拉菜單。我將第三級子菜單定位在父菜單的左側,但頂部位置沒有正確對齊。下拉菜單的定位
屏幕下方是我得到的結果。
CSS代碼:
/* the menu_new_new is the list, you don't need a wrapping div */
#menu_new{
Text-Align: Left;
/*width:100%;*/
background:#194eb1;
/* height:30px;*/
}
/* only mainmenu_new listitems */
#menu_new > li{
display:inline-block;
position:relative;
line-height:35px;
}
/* links in mainmenu_new and both submenu_news */
#menu_new a{
display:block;
text-decoration:none;
padding:0px 10px;
color:#fff;
text-align:Left;
}
/* submenu_news of both levels */
#menu_new li ul{
position: absolute;
top: 35px;
left:0;
min-width:150px;
background: #194eb1;
Text-Align: Left;
}
/* submenu text */
#menu_new li ul li{
Text-Align: Left;
line-height:20px;
List-style-type:none;
border: 1px solid white;
}
/* move the second level submenu_new to the right to don't overlap the parent submenu_new */
#menu_new ul ul{
position: absolute;
top:auto;
left:150px;
Z-index: 10;
}
/* hover effect for submenu_new links */
#menu_new li li a:hover{
background:rgba(255,255,255,0.5);
}
/* hide all submenu_news for default */
#menu_new li ul{
display: none;
}
/* show a submenu_new if the direct parent listitem is hovered */
#menu_new li:hover > ul{
display:block;
}
如何準確地對準頂部位置父菜單的位置?
請參考以下示例代碼:http://jsfiddle.net/asovbLqd/?
您可以使用http://jsfiddle.net/創建代碼演示並共享嗎?這將會更有幫助! – UID 2014-09-02 14:34:45
我已經在小提琴中創建了代碼。 http://jsfiddle.net/asovbLqd/請參閱此並幫助我。 – 2014-09-02 14:39:14
找到我的答案並在 – UID 2014-09-02 14:57:33