我使用 jquery 创建了一个下拉菜单,它显示内联,这是我希望它显示的方式,然后单击以显示其他选项。但是,一旦我单击该链接,它似乎会将 LI 标记放回块中。
任何人都知道它为什么这样做?
HTML
<!-- Navigation bar start -->
<div id="navbar">
<!-- England nav bar start -->
<li id="engmainnav"><a href="#">England</a>
<ul id="engsubnav">
<li class="engli"><? echo $this->Html->link('News', array('controller'=>'Premiership', 'action' =>'news')); ?></li>
<li class="engli"><? echo $this->Html->link('Results/Fixtures', array('controller'=>'Premiership', 'action' =>'resultsfixtures')); ?></li>
<li class="engli"><? echo $this->Html->link('Teams', array('controller'=>'Premiership', 'action' =>'teams')); ?></li>
<li class="engli"><? echo $this->Html->link('Table', array('controller'=>'Premiership', 'action' =>'table'));?></li>
</ul>
</li>
<!-- England nav bar end -->
<!-- La liga nav bar start-->
<li id="sanav"><a href="#">Italy</a>
<ul id="sasubnav">
<li class="sali"><? echo $this->Html->link('News', array('controller'=>'Italy', 'action' =>'news')); ?></li><br/>
<li class="sali"><? echo $this->Html->link('Results/Fixtures', array('Italy'=>'Premiership', 'action' =>'resultsfixtures')); ?></li><br/>
<li class="sali"><? echo $this->Html->link('Teams', array('controller'=>'Italy', 'action' =>'teams')); ?></li><br/>
<li class="sali"><? echo $this->Html->link('Table', array('controller'=>'Seriea', 'action' =>'table'));?></li><br/>
</ul>
</li>
</div>
<!-- Navigation bar end -->
CSS
/* Navigation Style */
#navbar {
background-color: #000666;
margin: 0px 0px 0px 10px;
}
#engsubnav {
list-style: none;
margin:none;
display: none;
}
#sasubnav{
list-style: none;
margin:none;
display: none;
}
.engli {
margin: 0px 0px 0px -38px;
display:block;
}
li {
list-style: none;
margin: 0px 0px 0px 10px;
display:inline;
}
ul{
display:inline;
}
提前感谢您的帮助