2014-12-05 71 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