2016-02-29 129 views
0

我正在開發iphone和ipad的網頁。我創建了一個導航工具欄,在ipad上看起來不錯,但在iphone上只有兩個超鏈接出現!任何人都可以告訴我如何縮小導航工具欄,以便所有超鏈接顯示在iphone 6屏幕上?(我希望所有導航欄超鏈接都顯示在iphone和ipad上)。提前致謝?如何調整iphone和ipad的導航工具欄寬度?

ul#navigation { 
 
    height: 70px; 
 
    list-style: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    border: 1px solid #ccc; 
 
    border-width: 1px 0; 
 
    text-align: center; 
 
    font-size: 22px; 
 
    font-family: 'Cham-WebFont', Arial, sans-serif; 
 
    background-color: #FFF; 
 
    position: fixed; 
 
    /* new */ 
 
    bottom: 0; 
 
    /* new */ 
 
    width: 100%; 
 
    /* new */ 
 
    } 
 
    ul#navigation li { 
 
    display: inline; 
 
    margin-right: .75em; 
 
    list-style: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    } 
 
    ul#navigation li.last { 
 
    margin-right: 0; 
 
    } 
 
    #MenuContainer { 
 
    text-align: center; 
 
    margin: 50px auto; 
 
    } 
 
    #MenuContainer a { 
 
    margin: 0px 20px; 
 
    display: inline-block; 
 
    text-decoration: none; 
 
    color: black; 
 
    }
<meta name="apple-mobile-web-app-capable" content="yes"> 
 
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0"> 
 
<link href="http://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet" type="text/css"> 
 
<link href="./TEST.css" rel="stylesheet" type="text/css"> 
 
<div id="MenuContainer"> 
 
    <ul id="navigation"> 
 

 
    <li class="x"> 
 
     <a title="1" href="./test.php?a"> 
 
     <img id="Button1" src="./1.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">First</div> 
 
     </a> 
 
    </li> 
 
    <li class="x"> 
 
     <a title="2" href="./test.php" onclick="location.href=this.href+'?b&id='+currentID;return false;"> 
 
     <img id="Button2" src="./2.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">Second</div> 
 
     </a> 
 
    </li> 
 
    <li class="x"> 
 
     <a title="3" href="./test.php?c"> 
 
     <img id="Button3" src="./2.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">Third</div> 
 
     </a> 
 
    </li> 
 
    <li class="x"> 
 
     <a title="4" href="./test.php?d"> 
 
     <img id="Button4" src="./3.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">Fourth</div> 
 
     </a> 
 
    </li> 
 
    <li class="x"> 
 
     <a title="5" href="./test.php?e"> 
 
     <img id="Button5" src="./4.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">Fifth</div> 
 
     </a> 
 
    </li> 
 
</ul> 
 
</div>

+0

您可以簡單地爲每個「li」使用百分比寬度,並將它們作爲浮動塊或內聯塊。我不會推薦這樣做,因爲小屏幕設備中的一行中的5個鏈接可能不是用戶最友好的。你的決定。 – Aziz

回答

0

您可以取代height:70px;max-height: 100%; min-height:70px;

見段:

ul#navigation { 
 
    max-height: 100%; 
 
    min-height:70px; 
 
    list-style: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    border: 1px solid #ccc; 
 
    border-width: 1px 0; 
 
    text-align: center; 
 
    font-size: 22px; 
 
    font-family: 'Cham-WebFont', Arial, sans-serif; 
 
    background-color: #FFF; 
 
    position: fixed; 
 
    /* new */ 
 
    bottom: 0; 
 
    /* new */ 
 
    width: 100%; 
 
    /* new */ 
 
    } 
 
    ul#navigation li { 
 
    display: inline; 
 
    margin-right: .75em; 
 
    list-style: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    } 
 
    ul#navigation li.last { 
 
    margin-right: 0; 
 
    } 
 
    #MenuContainer { 
 
    text-align: center; 
 
    margin: 50px auto; 
 
    } 
 
    #MenuContainer a { 
 
    margin: 0px 20px; 
 
    display: inline-block; 
 
    text-decoration: none; 
 
    color: black; 
 
    }
<div id="MenuContainer"> 
 
    <ul id="navigation"> 
 
    <li class="x"> 
 
     <a title="1" href="./test.php?a"> 
 
     <img id="Button1" src="./1.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">First</div> 
 
     </a> 
 
    </li> 
 
    <li class="x"> 
 
     <a title="2" href="./test.php" onclick="location.href=this.href+'?b&id='+currentID;return false;"> 
 
     <img id="Button2" src="./2.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">Second</div> 
 
     </a> 
 
    </li> 
 
    <li class="x"> 
 
     <a title="3" href="./test.php?c"> 
 
     <img id="Button3" src="./2.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">Third</div> 
 
     </a> 
 
    </li> 
 
    <li class="x"> 
 
     <a title="4" href="./test.php?d"> 
 
     <img id="Button4" src="./3.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">Fourth</div> 
 
     </a> 
 
    </li> 
 
    <li class="x"> 
 
     <a title="5" href="./test.php?e"> 
 
     <img id="Button5" src="./4.png" alt="" width="42" height="42" border="0"> 
 
     <div class="caption">Fifth</div> 
 
     </a> 
 
    </li> 
 
</ul>

+0

感謝您的回覆。我在ipad上測試過它顯示超過5個鏈接中的4個,並且在iphone上它顯示了第一行中的3個超鏈接,第二行中僅顯示了其他兩個超鏈接的一部分?是否顯示兩個設備中的一行上的所有5個hyprlinks或在一行中顯示3,在第二行顯示2? – user1788736

+1

@ user1788736您可以隨時查看dropdowns @ https://css-tricks.com/convert-menu-to-dropdown/或按比例縮小到設備的寬度,但可能會導致意外按錯鏈接的問題如果太小。 –

+0

感謝您提供下拉方法,我會稍後測試該選項。我在css中更改了文本的字體,並且獲得了更多空間。我怎樣才能減少不同超鏈接之間的差距? – user1788736