2015-07-10 21 views
0

我對html/css編程很新鮮,所以請原諒我,如果這是一個新手的錯誤。如何縮小寬度大小超鏈接?

我已經開始了一個新的網頁 - http://robingham.co.uk/LUUCC4/index.php

我決定嘗試獲得固定的導航和菜單欄整理第一。

我希望菜單按鈕和站點的徽標位於固定導航欄內。正如你所看到的,我已經把它整理出來了。有一些我需要做的小事情,比如對齊菜單按鈕。但功能似乎工作正常。

我現在試圖解決的問題是該徽標具有屏幕寬度大小的超鏈接區域。我已經添加了一個指向該徽標的超鏈接,以便用戶可以通過點擊返回到主頁。不管屏幕的大小如何,我也希望徽標水平居中。我相信這個問題與事實有關,我必須使用display: block;才能使水平中心對齊工作,但我不知道如何修復超鏈接。

我該如何修復它?

謝謝

我的index.php是。

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
    <link rel="icon" type="image/ico" href="http://www.robingham.co.uk/LUUCC3/media/favicon.ico"> 
    <link type="text/css" rel="stylesheet" href="http://www.robingham.co.uk/LUUCC3/styles/general_formatting.css"/> 
    <title>LUUCC-Build</title> 
    <meta charset="UTF-8" /> 
    <script src="http://www.robingham.co.uk/LUUCC3/scripts/jquery-1.11.3.min.js"></script> 
    <script src="http://www.robingham.co.uk/LUUCC3/scripts/menu_function.js"></script> 
</head> 


<body> 
    <div id="header_bar"> 
     <img class="icon-menu" src="media/menu.png" width="40" height="40" alt="Menu button"/> 
     <!--<a href="http://www.robingham.co.uk"><img id="header_bar_menu" src="media/menu.png" width="40" height="40" alt="Menu button"/></a>--> 
     <div><a href="http://www.robingham.co.uk/LUUCC/index.php"><img id="header_bar_logo" src="media/header_bar_logo.png" width="315" height="65" alt="LUUCC logo"/></a></div> 
    </div> 

    <div class="menu"> 
     <!-- Menu icon --> 
     <div class="icon-close"> 
     <img src="http://www.robingham.co.uk/LUUCC3/media/close.png"> 
     </div> 

     <!-- Menu --> 
     <ul> 
     <li><a href="#">About</a></li> 
     <li><a href="#">Blog</a></li> 
     <li><a href="#">Help</a></li> 
     <li><a href="#">Contact</a></li> 
     </ul> 
    </div> 




    </div id="body_material"> 
    <p>test1</p> 
    <p>test2</p> 
    <p>test3</p> 
    <p>test4</p> 
    <p>test5</p> 
    <p>test6</p> 
    <p>test7</p> 
    <p>test8</p> 
    <p>test9</p> 
    <p>test10</p> 
    <p>test221</p> <!--Removed some of these for the sake of the post--> 
    <p>test221</p> 
    <p>test221</p> 
    <p>test221</p> 
    <p>test221</p> 
    </div> 
</body> 
</html> 

我的CSS代碼是。

body { 
    background-color: #00FFF0; /*#f6f6f6*/ 
} 

#header_bar { 
    z-index: 1; 
    position: fixed; 
    width: 100%; 
    top: -1px; 
    left: -1px; 
    height: 65px; /**/ 
    background-color: #FFFFFF; /*FFFFFF*/ 
    border:1px solid #ccc; 
} 

#header_bar_menu{ 
    display: inline-block; 
    /*vertical-align: 9px; 
    margin-left: 10px;*/ 
    border:4px solid #000000; 
    margin-left: 15px; 
    margin-top: 15px; 
} 

#header_bar_logo { 
    /*display: inline-block; 
    margin-left: 500px;*/ 
    /*display: inline-block; 
    text-align:center;*/ 
    display: block; 
    margin-left: auto; 
    margin-right: auto; 
    margin-top: -95px; /*-60*/ 
} 

.menu { 
    background: #202024; 
    left: -285px; /* start off behind the scenes */ 
    top: 65px; 
    height: 100%; 
    position: fixed; 
    width: 285px; 
} 

.menu ul { 
    border-top: 1px solid #636366; 
    list-style: none; 
    margin: 0; 
    padding: 0; 
} 
/**/ 
.menu li { 
    border-bottom: 1px solid #636366; 
    font-family: 'Open Sans', sans-serif; 
    line-height: 45px; 
    padding-bottom: 3px; 
    padding-left: 20px; 
    padding-top: 3px; 
} 

.menu a { 
    color: #fff; 
    font-size: 15px; 
    text-decoration: none; 
    text-transform: uppercase; 
} 

.icon-close { 
    cursor: pointer; 
    padding-left: 10px; 
    padding-top: 10px; 
} 

.icon-menu { 
    color: #fff; 
    cursor: pointer; 
    font-family: 'Open Sans', sans-serif; 
    font-size: 16px; 
    padding-bottom: 25px; 
    padding-left: 25px; 
    padding-top: 25px; 
    text-decoration: none; 
    text-transform: uppercase; 
} 

.icon-menu i { 
    margin-right: 5px; 
} 
+0

我在我的代碼一點點複製和粘貼錯誤與我的一些目錄。 雷的解決方案像魔術一樣工作。謝謝。 –

回答

2

body { 
 
    background-color: #f6f6f6; /*#f6f6f6*/ 
 
} 
 

 
#header_bar { 
 
\t z-index: 1; 
 
\t position: fixed; 
 
\t width: 100%; 
 
\t top: -1px; 
 
\t left: -1px; 
 
\t height: 65px;/**/ 
 
\t background-color: #FFF;/*FFFFFF*/ 
 
\t border:1px solid #ccc; 
 
    text-align: center; 
 
} 
 

 
#header_bar_menu{ 
 
\t display: inline-block; 
 
\t /*vertical-align: 9px; 
 
\t margin-left: 10px;*/ 
 
\t border:4px solid #000000; 
 
\t margin-left: 15px; 
 
    margin-top: 15px; 
 
} 
 

 
#header_bar_logo { 
 
\t /*display: inline-block; 
 
\t margin-left: 500px;*/ 
 
\t /*display: inline-block; 
 
\t text-align:center;*/ 
 
\t /* display: block; */ 
 
\t /* margin-left: auto; */ 
 
\t /* margin-right: auto; */ 
 
\t /* margin-top: -95px; *//*-60*/ 
 
} 
 

 
.menu { 
 
    background: #202024; /* url('http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/black-thread.png') repeat left top;*/ 
 
    left: -285px; /* start off behind the scenes */ 
 
    top: 65px; 
 
    height: 100%; 
 
    position: fixed; 
 
    width: 285px; 
 
} 
 

 
.menu ul { 
 
    border-top: 1px solid #636366; 
 
    list-style: none; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
/**/ 
 
.menu li { 
 
    border-bottom: 1px solid #636366; 
 
    font-family: 'Open Sans', sans-serif; 
 
    line-height: 45px; 
 
    padding-bottom: 3px; 
 
    padding-left: 20px; 
 
    padding-top: 3px; 
 
} 
 

 
.menu a { 
 
    color: #fff; 
 
    font-size: 15px; 
 
    text-decoration: none; 
 
    text-transform: uppercase; 
 
} 
 

 
.icon-close { 
 
    cursor: pointer; 
 
    padding-left: 10px; 
 
    padding-top: 10px; 
 
} 
 

 
.icon-menu { 
 
    color: #fff; 
 
    cursor: pointer; 
 
    font-family: 'Open Sans', 
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    sans-serif; 
 
    font-size: 16px; 
 
    /* padding-bottom: 25px; */ 
 
    /* padding-left: 25px; */ 
 
    /* padding-top: 25px; */ 
 
    text-decoration: none; 
 
    text-transform: uppercase; 
 
    position: absolute; 
 
    left: 1rem; 
 
    top: 1rem; 
 
} 
 

 
.icon-menu i { 
 
    margin-right: 5px; 
 
}
<base href="http://robingham.co.uk/LUUCC4/index.php"/> 
 
<div id="header_bar"> 
 
\t  <img class="icon-menu" src="media/menu.png" width="40" height="40" alt="Menu button"/> 
 
\t \t <!--<a href="http://www.robingham.co.uk"><img id="header_bar_menu" src="media/menu.png" width="40" height="40" alt="Menu button"/></a>--> 
 
\t \t <a href="http://www.robingham.co.uk/LUUCC4/index.php"><img id="header_bar_logo" src="media/header_bar_logo.png" width="315" height="65" alt="LUUCC logo"/></a> 
 
\t </div> 
 
\t 
 
\t <div class="menu"> 
 
     <!-- Menu icon --> 
 
     <div class="icon-close"> 
 
     <img src="http://www.robingham.co.uk/LUUCC4/media/close.png"> 
 
     </div> 
 

 
     <!-- Menu --> 
 
     <ul> 
 
     <li><a href="#">About</a></li> 
 
     <li><a href="#">Blog</a></li> 
 
     <li><a href="#">Help</a></li> 
 
     <li><a href="#">Contact</a></li> 
 
     </ul> 
 
    </div> 
 
\t 
 

 
\t </div id="body_material"> 
 
\t <p>test1</p> 
 
\t <p>test2</p> 
 
\t <p>test3</p> 
 
\t <p>test4</p> 
 
\t <p>test5</p> 
 

 
\t </div>

+0

非常感謝你。工作過一種享受。 –

+0

我按下輸入得太快。 非常感謝你。工作過一種享受! 感謝指向基本標記的指針。尼斯。 Ps。我知道我不需要明確說明我的資源在哪裏,因爲它應該來自根文件夾。但是,正如你從複製和粘貼中猜測出的,我正在運行同一網站的多個版本,一旦我有了一些工作,我將移動到下一節的新文件夾,所以舊的文件夾成爲當前狀態的備份。 也感謝給我的代碼對齊菜單按鈕。 謝謝。 –

+0

我剛剛添加了基本標記,以便在堆棧溢出時在此處運行片段時加載圖像。 ;) 如果你能正式接受我的回答,我會很感激。謝謝! – ray

0

鳥巢鏈接和標誌,像這樣:

<a> 
    <img src="this_is_my_logo.png" /> 
</a> 
相關問題