宽度上的菜单导航CSS

时间:2014-05-07 20:17:31

标签: jquery html css css3

我的菜单列表宽度有问题,它们有不同的宽度。我应该怎么做才能为它们设置更大的宽度? 我下载了插件here

现场演示:live demo

.menu-collapser {
    position: relative;
    background-color: #999;
    color: #FFF;
    text-shadow: 0 1px 0 rgba(0,0,0,0.5);
    width: 100%;
    height: 48px;
    line-height: 48px;
    font-size: 16px;
    padding: 0 8px;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box
}
.collapse-button {
    position: absolute;
    right: 8px;
    top: 50%;
    width: 40px;
    background-color: #0E0E0E;
    background-image: linear-gradient(to bottom, #151515, #040404);
    background-repeat: repeat-x;
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
    border-radius: 4px 4px 4px 4px;
    border-style: solid;
    border-width: 1px;
    color: #FFFFFF;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 1px 0 rgba(255, 255, 255, 0.075);
    padding: 7px 10px;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
    cursor: pointer;
    font-size: 14px;
    text-align: center;

    transform: translate(0, -50%);
    -o-transform: translate(0, -50%);
    -ms-transform: translate(0, -50%);
    -moz-transform: translate(0, -50%);
    -webkit-transform: translate(0, -50%);

    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box
}
.collapse-button:hover, .collapse-button:focus {
    background-image: none;
    background-color: #040404;
    color: #FFF;
}
.collapse-button .icon-bar {
    background-color: #F5F5F5;
    border-radius: 1px 1px 1px 1px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
    display: block;
    height: 2px;
    width: 18px;
    margin: 2px 0;
}

ul.slimmenu {
    list-style-type: none;
    margin: 0;
    padding: 0;
    width: 100%;
}
ul.slimmenu li {
    position: relative;
    display: inline-block;
    background-color: #AAA;
}
ul.slimmenu > li { margin-right: -5px; border-left: 1px solid #999 }
ul.slimmenu > li:first-child { border-left: 0 }
ul.slimmenu > li:last-child { margin-right: 0 }
ul.slimmenu li a {
    max-width: 250px;
    display: block;
    color: #333;
    padding: 12px 64px 12px 16px;
    font-family: 'Roboto Slab', serif;
    font-size: 16px;
    font-weight: 400;
    text-shadow: 0 1px 0 rgba(255,255,255,0.2);
    transition: background-color 0.5s ease-out;
    -o-transition: background-color 0.5s ease-out;
    -moz-transition: background-color 0.5s ease-out;
    -webkit-transition: background-color 0.5s ease-out;
}
ul.slimmenu li a:hover {
    background-color: #999;
    text-decoration: none;
}
ul.slimmenu li .sub-collapser {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0.075);
    position: absolute;
    right: 0;
    top: 0;
    width: 48px;
    height: 100%;
    text-align: center;
    z-index: 999;
    cursor: pointer;
}
ul.slimmenu li .sub-collapser:before {
    content: '';
    display: inline-block;
    height: 100%;
    vertical-align: middle;
    margin-right: -0.25em;
}
ul.slimmenu li .sub-collapser > i {
    color: #333;
    font-size: 18px;
    display: inline-block;
    vertical-align: middle;
}
ul.slimmenu li ul {
    margin: 0;
    list-style-type: none;
}
ul.slimmenu li ul li { background-color: #BBB }
ul.slimmenu li > ul {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    z-index: 999;
    width: 100%;
}
ul.slimmenu li > ul > li ul {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    z-index: 999;
    width: 100%;
}

ul.slimmenu.collapsed li {
    display: block;
    width: 100%;

    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box
}
ul.slimmenu.collapsed li a {
    display: block;
    border-bottom: 1px solid rgba(0, 0, 0, 0.075);

    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box
}
ul.slimmenu.collapsed li .sub-collapser {
    height: 40px;
}
ul.slimmenu.collapsed li > ul {
    display: none;
    position: static;
}

如果您需要更多详情,请告诉我。

3 个答案:

答案 0 :(得分:0)

试试这个:

ul.slimmenu li ul li {
   background-color: #BBB;
   width: inherit;
}

答案 1 :(得分:0)

只需为它们设置宽度

您已有规则( style.css文件的第500行),只需添加width属性

ul.slimmenu li {
    background-color: #AAAAAA;
    display: inline-block;
    position: relative;
    width: 200px; /*ADD THIS LINE*/
}

答案 2 :(得分:0)

不使用宽度设置,而是使用块元素的自然行为。

在此处添加display: block

ul.slimmenu li ul li { background-color: #BBB; display: block; }

父元素(ul)设置为块1。通过将其子(li)设置为display: block - 您自然会告诉"他们要占用他们父母的全宽。