2016-04-05 17 views
1

如何減少CSS中<nav>標記的大小?我似乎無法弄清楚。我已經提供了下面我項目的所有代碼。我的代碼確實有PHP,但我已經刪除它,因爲它是不必要的。這裏是一個JSFiddle,如果你想在那裏預覽代碼。如何在html或css中設置<nav>的高度

HTML和CSS:

#top-menu { 
 
    top: 0; 
 
    position: fixed; 
 
} 
 
nav { 
 
    position: relative; 
 
    /*float: left;*/ 
 
    width: 100%; 
 
    background: #1E1E1E; 
 
    /* display: table; */ 
 
    margin: 0; 
 
    text-align: center; 
 
    height: 25px; 
 
    border: none; 
 
    border-width: 0; 
 
    margin: 0; 
 
    padding: 10px 10px; 
 
} 
 
nav ul ul { 
 
    display: none; 
 
} 
 
nav ul li:hover > ul { 
 
    display: block; 
 
    border: none; 
 
    border-width: 0; 
 
} 
 
nav ul { 
 
    background: #1E1E1E; 
 
    color: white; 
 
    padding: 10px 10px; 
 
    border-radius: 0; 
 
    list-style: none; 
 
    position: relative; 
 
    display: inline-table; 
 
    border-width: 0; 
 
    border: none; 
 
} 
 
nav ul:after { 
 
    content: ""; 
 
    clear: both; 
 
    display: block; 
 
} 
 
nav ul li { 
 
    float: left; 
 
    border: none; 
 
    border-width: 0; 
 
} 
 
nav ul li:hover { 
 
    background: #1E1E1E; 
 
    background-color: orange; 
 
    color: white; 
 
} 
 
nav ul li:hover a { 
 
    color: #fff; 
 
} 
 
nav ul li a { 
 
    display: block; 
 
    height: 25px; 
 
    padding: 10px 10px; 
 
    color: #757575; 
 
    text-decoration: none; 
 
    border: none; 
 
    border-width: 0; 
 
} 
 
nav ul ul { 
 
    background: #1E1E1E; 
 
    color: white; 
 
    border-radius: 0px; 
 
    padding: 10px 10px; 
 
    position: absolute; 
 
    top: 50px; 
 
    border-width: 0; 
 
    margin-bottom: 0; 
 
} 
 
nav ul ul li { 
 
    float: none; 
 
    border-top: 1px solid #6b727c; 
 
    border-bottom: 1px solid #575f6a; 
 
    position: relative; 
 
} 
 
nav ul ul li a { 
 
    padding: 10px 10px; 
 
    color: #fff; 
 
    height: auto; 
 
} 
 
nav ul ul li a:hover { 
 
    background: #4b545f; 
 
    background-color: orange; 
 
} 
 
nav ul ul ul { 
 
    position: absolute; 
 
    left: 100%; 
 
    top: 0; 
 
} 
 
nav li#english a { 
 
    background: url(images/english.jpg) no-repeat; 
 
    background-position: center center; 
 
} 
 
nav li#english a:hover { 
 
    background: url(images/english.jpg) no-repeat; 
 
    background-position: center center; 
 
    background-color: orange; 
 
} 
 
nav li#english a.current { 
 
    background: url(images/english.jpg) no-repeat; 
 
    background-position: center center; 
 
    cursor: default; 
 
} 
 
/*--------------------------------------------*/ 
 

 
#menu { 
 
    background-color: #1E1E1E; 
 
    text-align: center; 
 
    padding-bottom: 0px; 
 
} 
 
body { 
 
    margin: 0px; 
 
} 
 
.clearfloat { 
 
    clear: both; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
/*--------------------------------------------*/ 
 

 
#bottom { 
 
    float: left; 
 
    width: 100%; 
 
    background: #1E1E1E; 
 
    /*display: table; */ 
 
    margin: 0; 
 
    text-align: center; 
 
    min-height: 25px; 
 
    height: 25px; 
 
    border-width: 0px; 
 
    margin-top: 0px; 
 
    padding-top: 0px; 
 
    bottom: 0px; 
 
    position: fixed; 
 
} 
 
#bottom ul ul { 
 
    display: none; 
 
} 
 
#bottom ul li:hover > ul { 
 
    display: block; 
 
} 
 
#bottom ul { 
 
    background: #1E1E1E; 
 
    color: white; 
 
    padding: 0 0; 
 
    border-radius: 0; 
 
    list-style: none; 
 
    position: relative; 
 
    display: inline-table; 
 
} 
 
#bottom ul:after { 
 
    content: ""; 
 
    clear: both; 
 
    display: block; 
 
} 
 
#bottom ul li { 
 
    float: left; 
 
} 
 
#bottom ul li:hover:nth-child(1) { 
 
    background: #1E1E1E; 
 
    color: #757575; 
 
    text-decoration: none; 
 
} 
 
#bottom ul li:hover:nth-child(2) { 
 
    background: #1E1E1E; 
 
    color: #757575; 
 
    text-decoration: none; 
 
} 
 
#bottom ul li:hover { 
 
    background: #1E1E1E; 
 
    color: white; 
 
    text-decoration: underline; 
 
} 
 
#bottom ul li:hover a { 
 
    color: #fff; 
 
} 
 
#bottom ul li a { 
 
    display: block; 
 
    padding: 25px 40px; 
 
    color: #757575; 
 
    text-decoration: none; 
 
} 
 
#bottom ul ul { 
 
    background: #1E1E1E; 
 
    color: white; 
 
    border-radius: 0px; 
 
    padding: 0; 
 
    position: absolute; 
 
    top: 100%; 
 
    width: auto; 
 
} 
 
#bottom ul ul li { 
 
    float: none; 
 
    border-top: 1px solid #6b727c; 
 
    border-bottom: 1px solid #575f6a; 
 
    position: relative; 
 
} 
 
#bottom ul ul li a { 
 
    padding: 15px 40px; 
 
    color: #fff; 
 
} 
 
#bottom ul ul li a:hover { 
 
    background: #4b545f; 
 
} 
 
#bottom ul ul ul { 
 
    position: absolute; 
 
    left: 100%; 
 
    top: 0; 
 
} 
 
/*--------------------------------------------*/ 
 

 
.bottommenuitem { 
 
    vertical-align: middle; 
 
    padding: 25px 40px; 
 
    color: #757575; 
 
}
<!DOCTYPE html5> 
 
<html> 
 

 
<head> 
 
    <title>Firma A/S</title> 
 
    <meta charset="UTF-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
    <link rel="stylesheet" type="text/css" href="cssMenu.css"> 
 
</head> 
 

 
<body> 
 
    <nav id="top-menu"> 
 
    <p id="menu" style="margin-bottom: -25"> 
 
     <a href="Index.html"> 
 
     <img src="Tilbage.jpg" alt="Tilbage" width="243" height="243" /> 
 
     </a> 
 
     <img src="Top_10.jpg" alt="" width="739" height="243" /> 
 
    </p> 
 
    <nav id="top"> 
 
     <ul> 
 
     <li><a href="index.php">Velkommen</a> 
 
     </li> 
 
     <li><a href="index.php">Firma A/S</a> 
 
      <ul> 
 
      <li><a href="index.php">Koncern oversigt</a> 
 
       <ul> 
 
       <li><a href="index.php">Ejendomsselskaber</a> 
 
       </li> 
 
       <li><a href="index.php">Investeringsselskaber</a> 
 
       </li> 
 
       <li><a href="index.php">Øvrige selskaber</a> 
 
       </li> 
 
       <li><a href="index.php">Lukkede eller solgte selskaber</a> 
 
       </li> 
 
       </ul> 
 
      </li> 
 
      <li><a href="index.php">Jubilæum</a> 
 
      </li> 
 
      <li><a href="index.php">Årsrapport</a> 
 
      </li> 
 
      <li><a href="index.php">Galleri</a> 
 
      </li> 
 
      <li><a href="index.php">Kontaktoplysninger</a> 
 
      </li> 
 
      </ul> 
 
     </li> 
 
     <li><a href="index.php">Privat</a> 
 
     </li> 
 
     <li><a href="index.php">Køb og salg</a> 
 
     </li> 
 
     <li><a id="english" href="index.php">In English</a> 
 
     </li> 
 
     </ul> 
 
     <!-- PHP was here --> 
 
    </nav> 
 
    </nav> 
 
    <div style="margin-top: 410; margin-bottom: 115"> 
 
    <!-- More PHP was here --> 
 
    </div> 
 
    <nav id="bottom"> 
 
    <ul> 
 
     <li class="bottommenuitem">Firma A/S</li> 
 
     <li class="bottommenuitem">phone No</li> 
 
     <li><a href="mailto:[email protected]">[email protected]</a> 
 
     </li> 
 
    </ul> 
 
    </nav> 
 
</body> 
 

 
</html>

任何幫助表示讚賞,謝謝。

+0

什麼/哪個html標籤? – LGSon

+0

@LGSon:NAV標籤 –

+0

你想什麼時候降低高度? – hardcoder

回答

0

請試試這個:

nav ul { 
    background: #1e1e1e none repeat scroll 0 0; 
    border: medium none; 
    border-radius: 0; 
    color: white; 
    display: inline-table; 
    list-style: outside none none; 
    margin: 0; 
    padding: 10px; 
    position: relative; 
} 
0

nav { 
 
    float: left; 
 
    width: 100%; 
 
    background: #1E1E1E; 
 
    display: table; 
 
    margin: 0; 
 
    text-align: center; 
 
    height: 25px; 
 
    border: none; 
 
    border-width: 0; 
 
    margin: 0; 
 
    padding: 10px 10px; 
 
} 
 
nav ul ul { 
 
    display: none; 
 
} 
 
nav ul li:hover > ul { 
 
    display: block; 
 
    border: none; 
 
    border-width: 0; 
 
} 
 
nav ul { 
 
    background: #1E1E1E; 
 
    color: white; 
 
    padding: 10px 10px; 
 
    border-radius: 0; 
 
    list-style: none; 
 
    position: relative; 
 
    display: inline-table; 
 
    border-width: 0; 
 
    border: none; 
 
} 
 
nav ul:after { 
 
    content: ""; 
 
    clear: both; 
 
    display: block; 
 
} 
 
nav ul li { 
 
    float: left; 
 
    border: none; 
 
    border-width: 0; 
 
} 
 
nav ul li:hover { 
 
    background: #1E1E1E; 
 
    background-color: orange; 
 
    color: white; 
 
} 
 
nav ul li:hover a { 
 
    color: #fff; 
 
} 
 
nav ul li a { 
 
    display: block; 
 
    height: 25px; 
 
    padding: 10px 10px; 
 
    color: #757575; 
 
    text-decoration: none; 
 
    border: none; 
 
    border-width: 0; 
 
} 
 
nav ul ul { 
 
    background: #1E1E1E; 
 
    color: white; 
 
    border-radius: 0px; 
 
    padding: 10px 10px; 
 
    position: absolute; 
 
    top: 50px; 
 
    border-width: 0; 
 
    margin-bottom: 0; 
 
} 
 
nav ul ul li { 
 
    float: none; 
 
    border-top: 1px solid #6b727c; 
 
    border-bottom: 1px solid #575f6a; 
 
    position: relative; 
 
} 
 
nav ul ul li a { 
 
    padding: 10px 10px; 
 
    color: #fff; 
 
    height: auto; 
 
} 
 
nav ul ul li a:hover { 
 
    background: #4b545f; 
 
    background-color: orange; 
 
} 
 
nav ul ul ul { 
 
    position: absolute; 
 
    left: 100%; 
 
    top: 0; 
 
} 
 
nav li#english a { 
 
    background: url(images/english.jpg) no-repeat; 
 
    background-position: center center; 
 
} 
 
nav li#english a:hover { 
 
    background: url(images/english.jpg) no-repeat; 
 
    background-position: center center; 
 
    background-color: orange; 
 
} 
 
nav li#english a.current { 
 
    background: url(images/english.jpg) no-repeat; 
 
    background-position: center center; 
 
    cursor: default; 
 
}
<nav id="top-menu"> 
 
    <p id="menu" style="margin-bottom: -25"> 
 
    <a href="Index.html"> 
 
     <img src="Tilbage.jpg" alt="Tilbage" width="243" height="243" /> 
 
    </a> 
 
    <img src="Top_10.jpg" alt="" width="739" height="243" /> 
 
    </p> 
 
    <nav id="top"> 
 
    <ul> 
 
     <li><a href="index.php">Velkommen</a> 
 
     </li> 
 
     <li><a href="index.php">Firma A/S</a> 
 
     <ul> 
 
      <li><a href="index.php">Koncern oversigt</a> 
 
      <ul> 
 
       <li><a href="index.php">Ejendomsselskaber</a> 
 
       </li> 
 
       <li><a href="index.php">Investeringsselskaber</a> 
 
       </li> 
 
       <li><a href="index.php">Øvrige selskaber</a> 
 
       </li> 
 
       <li><a href="index.php">Lukkede eller solgte selskaber</a> 
 
       </li> 
 
      </ul> 
 
      </li> 
 
      <li><a href="index.php">Jubilæum</a> 
 
      </li> 
 
      <li><a href="index.php">Årsrapport</a> 
 
      </li> 
 
      <li><a href="index.php">Galleri</a> 
 
      </li> 
 
      <li><a href="index.php">Kontaktoplysninger</a> 
 
      </li> 
 
     </ul> 
 
     </li> 
 
     <li><a href="index.php">Privat</a> 
 
     </li> 
 
     <li><a href="index.php">Køb og salg</a> 
 
     </li> 
 
     <li><a id="english" href="index.php">In English</a> 
 
     </li> 
 
    </ul> 
 

 
    </nav> 
 
</nav>

0

請與ID你想成爲特定高度的,如果你沒有得到預期的結果,那麼設置填充其資產淨值指定並在該導航裏面的文本的邊緣相應,以便它不影響您的導航高度。(在CSS文件中進行這些更改)

0

如果您重新討論固定的導航id = top-menu,只需爲CSS選擇器添加一個高度。這個對我有用。如果您在覆蓋時遇到問題,請確保將其放置在CSS文件的較低位置,或者在規則之後添加!important

#top-menu { 
    height: 6px; 
} 

#top-menu { 
    height: 6px !important; 
} 
+0

我試過了,沒有成功:-(0123 –

相關問題