我有一个导航菜单,在我的网站上显示一个无序的 <ul> 列表。我试图向它添加一些额外的参数,以便我可以通过 js 控制它的输出,因为我希望有时显示一些东西而不是其他时间隐藏它们。
问题是,只要我没有在 <li> 标签上应用任何 id 属性,输出就会非常好,一旦我这样做,它就会使布局拉伸并似乎自动为其添加填充。
<div id="navigation">
<ul id="jsddm" class="dbtree">
<li class="is-current" id="SHOP">
<a href="...">SHOP</a>
<ul>
<li id="JEWELLERY">
<a href="...">JEWELLERY</a>
<ul>
<li id="NECKLACES"><a href="...">NECKLACES</a></li>
</ul>
<ul>
<li id="RINGS"><a href="...">RINGS</a></li>
</ul>
<ul>
<li id="EARRINGS"><a href="...">EARRINGS</a></li>
</ul>
<ul>
<li id="FRIENDSHIP BRACELETS"><a href="...">FRIENDSHIP BRACELETS</a></li>
</ul>
<ul>
<li id="CHARM BRACELETS"><a href="...">CHARM BRACELETS</a></li>
</ul>
</li>
</ul>
<ul>
<li id="BESPOKE"><a href="...">BESPOKE</a>
<ul>
<li id="MAKE YOUR BESPOKE "><a href="...">MAKE YOUR BESPOKE</a></li>
</ul>
<ul>
<li id="CHAINS"><a href="...">CHAINS</a></li>
</ul>
<ul>
<li id="LETTERS"><a href="...">LETTERS</a></li>
</ul>
<ul>
<li id="CRYSTALS"><a href="...">CRYSTALS</a></li>
</ul>
<ul>
<li id="GEMSTONES"><a href="...">GEMSTONES</a></li>
</ul>
<ul>
<li id="CHARMS"><a href="...">CHARMS</a></li>
</ul>
<ul>
<li id="COLOURED CORD"><a href="...">COLOURED CORD</a></li>
</ul>
</li>
</ul>
<ul>
<li id="KA FINES (coming soon)"><a href="...">KA FINES (coming soon)</a></li>
</ul>
<ul>
<li id="GIFT VOUCHER"><a href="...">GIFT VOUCHER</a></li>
</ul>
<ul>
<li id="MY DETAILS"><a href="...">MY DETAILS</a></li>
</ul>
<ul>
<li id="MY HISTORY"><a href="...">MY HISTORY</a></li>
</ul>
<ul>
<li id="LOGOUT"><a href="...">LOGOUT</a></li>
</ul>
</li>
</ul>
<ul>
<li id="BESPOKE">
<a href="...">BESPOKE</a>
<ul>
<li id="ABOUT"><a href="...">ABOUT</a></li>
</ul>
<ul>
<li id="LOOKBOOK "><a href="...">LOOKBOOK</a></li>
</ul>
<ul>
<li id="MAKE YOUR BESPOKE"><a href="...">MAKE YOUR BESPOKE</a></li>
</ul>
</li>
</ul>
<ul>
<li id="LOOKBOOK "><a href="...">LOOKBOOK</a>
<ul>
<li id="BESPOKE LOOKBOOK"><a href="...">BESPOKE LOOKBOOK</a></li>
</ul>
<ul>
<li id="SOMETHING LIKE PARADISE"><a href="...">SOMETHING LIKE PARADISE</a></li>
</ul>
</li>
</ul>
<ul>
<li id="OUR STORY"><a href="...">OUR STORY</a></li>
</ul>
<ul>
<li id="PRESS"><a href="...">PRESS</a></li>
</ul>
<ul>
<li id="BLOG"><a href="...">BLOG</a></li>
</ul>
</div>
一旦我添加id="SHOP"
到第一个 <li> ( <div id="navigation"><ul id="jsddm" class="dbtree"><li class="is-current" id="SHOP">
),它就会通过添加额外的填充来破坏它,就像它忽略了样式表中的原始规则一样。
CSS:-
<style>
#navigation
{
width:160px;
float:left;
font-weight:normal;
font-family:'BulmerMTStd-Regular';
line-height:18px;
padding-bottom:10px;
font-size:12px;
}
#navigation ul{margin-left:0px; padding-left:0px;}
#navigation li{text-align:left; margin:0px; padding:0px;}
#navigation ul li{color:#000000; list-style:none; margin-left:0px; padding-left:0px; margin-top:0px;}
#navigation li ul{margin-left:0px; padding-left:0px; display:none;}
#navigation li a{color:#000000;font-family:'BulmerMTStd-Regular'; text-decoration:none; line- height:18px; padding-bottom:10px;}
#navigation li a:hover{color:#8a8888;}
#navigation li ul li ul{padding-left:10px; color:#8a8888;}
#navigation li ul li ul a{color:#8a8888;}
#navigation li ul li ul a:hover{color:#000000;}
#navigation{z-index:0}
</style>
我确定这可能是一个非常简单的问题......但我似乎无法解决它..任何帮助都非常感谢。