2014-12-05 72 views
0

请帮我用这个下拉式菜单排版。css下拉式菜单排版

这是我的排版现在:

enter image description here

而且我想这个词(Engliash和繁体中文(中国台湾)更紧密地这样

enter image description here

我尝试了一段时间,仍然不能试用 非常感谢你的指导

这里是我的代码:
#dropdownmenu是一个div下div其ID =头

的jsfiddle:http://jsfiddle.net/kkadso/yk3tprnv/1/

<ul id="header"> 
    <li data-menuanchor="firstPage"><a href="#">About</a> 
    </li> 
    <li> 
     <div id='dropmenu'> 
      <img src="{% static 'img/lan.png' %}" /> 
      <ul class="submenu"> 

       <input name="language" type="hidden" id="lang"/> 
       <li value="en" id="langtext"><a href="#" >English</a></li> 
       <li value="zh-tw" id="langtext"><a href="#" >Traditional Chinese(Taiwan)</a></li> 

      </ul> 
     </div> 
    </li> 
</ul> 
+0

把你的代码放在JSFiddle中。 – Karmacoma 2014-12-05 00:52:19

+0

http://jsfiddle.net/kkadso/yk3tprnv/1/这里! – user2492364 2014-12-05 01:08:40

回答

0

你应该遵循CSS的变化而变化:

#dropmenu { 
    position : relative; 
} 

#dropmenu > ul { 
    position: absolute; 
    background-color: #000; 
    display: none; //<- this should be uncommented 
    /*width: 100px;*/ //<-this should be commented 
} 
#dropmenu:hover > ul { 
    display: block!important; // !mportant must be added to show child content when hover 
    background: #666666; 
    padding-left: 0;   //<- This must be added 
} 
#dropmenu:hover > ul > li { 
    position : relative;  //<-This must be relative 
} 
#langtext > a { 
    font-size: 0.8rem; 
} 

#header { 
    text-align: center; 
    top: 0; 
    right: 0; 
    height: 60px; 
    z-index: 70; 
    width: 100%; 
    padding: 0; 
    margin: 0; 
    /* postition: relative; */ //<-This must be commented 
} 
#header li { 
    font-size: 1rem; 
    display: inline-block; 
    margin: 20px; 
    color: #e6e7e8; 
    text-align: left; // <- This must be added. Aligning text. 
} 
#header li.active { 
    color: #fff; 
} 
#header li a { 
    text-decoration: none; 
    color: #e6e7e8; 
} 
#header li.active a:hover { 
    color: #fff; 
} 
#header li:hover { 
    background-color: transparent; 
} 
#header li a, 
#header li.active a { 
    display: block; 
    white-space: pre; 
} 
#header li.active a { 
    color: #fff; 
    font-weight: 600; 
} 

这里是Demoenter image description here

+0

非常感谢! Engliash和繁体中文(台湾)的距离(它们之间是否有空间)更接近? ,对不起,我的英文表达不够好。 – user2492364 2014-12-05 02:11:02

+0

是的,您是否也需要它们? – Khamidulla 2014-12-05 02:13:41

+0

是的,我需要这个 – user2492364 2014-12-05 02:21:25