如何避免li标签中的ul形式?

时间:2013-06-28 16:44:48

标签: css

正如您在Item 1.2我看到的那样,我有空间,如何删除它?

它必须是侧边栏嵌套菜单。

HTML

<div class="sidebar">
<ul>
    <li>
     <a href="#">Item 1</a>
       <ul>
         <li><a href="#">Item 1.1</a></li>
         <li><a href="#">Item 1.2</a></li>
       </ul>    
    </li>
    <li><a href="#">Item 2</a></li>
    <li><a href="#">Item 3</a></li>
</ul>
</div>

CSS

.sidebar {
    background: none repeat scroll 0 0 #F4F4F4;
    float: left;
    min-height: 600px;
    width: 250px;
}


.sidebar ul {
    float: left;
    list-style: none outside none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.sidebar ul li {
    border: 1px solid;
    float: left;
    margin: 0;
    padding: 10px 0;
    width: 100%;
}

.sidebar ul li a {
    margin-left: 5px;
}

a:link, a:active, a:visited {
    border: medium none;
    color: inherit;
    font-size: inherit;
    text-decoration: none;
}

这里是小提琴css menu example

1 个答案:

答案 0 :(得分:2)

假设您需要相同的视觉边距/填充:

http://jsfiddle.net/2U4Uv/2/

.sidebar {
    background: none repeat scroll 0 0 #F4F4F4;
    float: left;
    min-height: 600px;
    width: 250px;
}


.sidebar ul {
    float: left;
    list-style: none outside none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.sidebar ul li {
    border: 1px solid;
    float: left;
    margin: 0;
    /*padding: 10px 0;*/
    width: 100%;
}

.sidebar ul li a {
    padding:10px 0;
    display:block;
    margin-left: 5px;
}

a:link, a:active, a:visited {
    border: medium none;
    color: inherit;
    font-size: inherit;
    text-decoration: none;
}