无序列表跳转到其他行

时间:2015-06-18 10:18:31

标签: css

我正在JSFiddle上创建一个dropline web菜单。我的问题是如何更改菜单在同一行显示的方式的定位。目前它下降并开始一条新线。

我的表http://jsfiddle.net/5jfsdwwu/17/

的示例
#menucontainer {
    margin: 0px;
    padding: 0px;
    width: 100%;
    height: 100px;
    position;
    relative;
}
#menucontainer ul {
    margin: 0px;
    padding: 0px;
    list-style: none;
    width: 600px;
    height:40px;
}
/* Following selector will define the style for individual parent menu. The following style gives them a look when the menus are not selected.
note that the position proerty is not set.
*/
 #menucontainer ul li.parent_menu {
    list-style: none;
    margin: 0px;
    padding: 10px;
    background-color:#bc3030;
    display: inline;
    width: 100%;
    height: 100%;
    border-right: 3px solid #bc3030;
}
/* 
Style for the anchor tag defined in the parent. 
*/
 #menucontainer ul li.parent_menu a {
    margin-left: 10px;
    padding-left: 10px;
    margin-right: 10px;
    padding-right: 10px;
    background-color: #bc3030;
    display: inline;
    text-decoration: none;
    font-family:"Raleway";
    font-size: 15px;
    color: #333333;
    line-height: 50px;
}
/* The hover effect is defined using the below selectors
For the background-color opacity is used to create a semi-transperant look as a hover effect
*/
 #menucontainer ul li.parent_menu:hover {
    list-style: none;
    margin: 0px;
    padding: 10px;
    opacity:0 background-color:#bc3030;
    display: inline;
    border-right:3px solid #bc3030;
}
/*
The following class will define the style for anchor tag in the 

*/
 #menucontainer ul li.parent_menu:hover a {
    list-style: none;
    margin-left: 10px;
    padding-left: 10px;
    margin-right: 10px;
    padding-right: 10px;
    background-color: #bc3030;
    display: inline;
    text-decoration: none;
    font-family:"Raleway";
    font-size: 15px;
    color: #333333;
    line-height: 33px;
}
/***************SUB MENU***********************/

/*
Following class will hide the sub menu when the mouse is not hovering.
*/
 #menucontainer ul li.parent_menu ul {
    margin: 0px;
    padding: 10px;
    list-style: none;
    display:none;
    position: absolute;
    height: 0;
}
/*
Following class display hide the sub menu when the mouse is not hovering.
Note: for this style of the menu position is set to 'absolute'

*/
 #menucontainer ul li.parent_menu:hover ul {
    margin: -5px 0 0 0;
    padding: 0px;
    list-style: none;
    display:block;
    position: absolute;
    height: auto;
    width:100%;
    background-color:#333333;
}
/* Following selector will define the style for individual sub menu. The following style gives them a look when the menus are not selected.
note that the position proerty is not set and dispaly is block.
Also the float property is set left; This will keep the menu in a single line.
*/
 #menucontainer ul li.parent_menu:hover ul li.child_menu {
    list-style: none;
    margin-left: 10px;
    padding-left: 10px;
    margin-right: 10px;
    padding-right: 10px;
    display: block;
    float: left;
}
/*
Following class will define the style for the anchor tag of the submenu/child menu
*/
 #menucontainer ul li.parent_menu:hover li.child_menu a {
    padding-left: 10px;
    margin-right: 10px;
    padding-right: 10px;
    background-color:transparent;
    display: inline;
    text-decoration: none;
    font-family:"Raleway";
    font-size: 15px;
    color: #bc3030;
    line-height: 33px;
}
#menucontainer ul li.parent_menu:hover li.child_menu a:hover {
    margin-left: 10px;
    padding-left: 10px;
    margin-right: 10px;
    padding-right: 10px;
    background-color:transparent;
    display: inline;
    text-decoration: none;
    font-family:"Raleway";
    font-size: 15px;
    color: #FFFFFF;
    line-height: 33px;
}

1 个答案:

答案 0 :(得分:0)

你的最后一个菜单选项是单独的ul,你的第一个ul的固定宽度是600px

将最后一个项目带到第一个ul,然后篡改你的宽度,你就会拥有它