2013-10-11 134 views
0

對不起,我又回到了另一個問題。我試圖通過刪除一些<div>標籤<section>,<header>等我的HTML頁面轉換爲HTML5。下拉菜單不再工作 - 下拉欄之間出現很大的差距。有人會介意看看嗎?提前致謝。HTML 5下拉菜單

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Home Page</title> 
<link rel="stylesheet" href="css.css"/> 
</head> 

<body> 
<div id= "container"> 
<header> 
    <img src="images/title.jpg"/> 
</header> 

<nav> 
<ul class="navbar"> 
<li> 
    <a href="#">Home</a> 
</li> 
<li> 
    <a href="#">HTML5</a> 
    <ul> 
     <li> 
      <a href="#">Tutorial 1</a> 
     </li> 
     <li> 
      <a href="#">Tutorial 2</a> 
     </li> 
     <li> 
      <a href="#">Tutorial 3</a> 
     </li> 
    </ul> 
</li> 
<li> 
    <a href="#">CSS3</a> 
    <ul> 
     <li> 
      <a href="#">Tutorial 1</a> 
     </li> 
     <li> 
      <a href="#">Tutorial 2</a> 
     </li> 
     <li> 
      <a href="#">Tutorial 3</a> 
     </li> 
    </ul> 
</li> 
<li> 
    <a href="#">Links</a> 
</li> 
<li> 
    <a href="#">Contact</a> 
</li> 
</ul> 
</nav> 

<section> 
<h2>Home Page</h2> 
<p>This is a test paragraph. .</p> 
</section> 

<footer> 
    <ul class="lowernav"> 
     <li><a href="#">Home</a></li> 
     <li><a href="#">HTML5</a></li> 
     <li><a href="#">CSS3</a></li> 
     <li><a href="#">Links</a></li> 
     <li><a href="#">Contact</a></li> 
    </ul> 
    <p id="copyright">Copyright blach blach blach!</p> 
</footer> 


</div> 

</body> 
</html> 

和CSS是:

@charset "utf-8"; 
/* CSS Document */ 
#container{ 
    width:800px; 
    background-color:#00FF00; 
    border:1px solid black; 
    height:1000px; 
    z-index:-9; 
    margin:auto; 
} 

#logo{ 

    background-color:#FF0033; 
    border:#000 1px; 
    width:800px; 
    height:200px; 
    overflow:hidden; 

} 

nav { 

    background-color:#FFF; 
    border:#000 1px; 
    width:800px; 
    height:30px; 

} 

section{ 

    background-color:#6F3; 
    border:#000 1px; 
    width:780px; 
    height:400px; 
    margin:10px; 
} 

footer{ 

    background-color:#FF0; 
    border:#000 1px; 
    width:800px; 
    height:100px; 
} 

.navbar { 
/*border-right: 1px solid #54879D;*/ 
    height: 40px; 
margin: 0 0 0 0; 
padding: 0; 

} 

.navbar li { 
background-color: #366B82; 
float: left; 
font: bold 12px/1.2em Arial,Verdana,Helvetica; 
height: auto; 
list-style: none outside none; 
margin: 20 0; 
padding: 0; 
text-align: center; 
width: 160px; 
} 

.navbar a { 
/* border-left: 1px solid #54879D;*/ 
border-right: 1px solid #1F5065; 
color: #FFFFFF; 
display: block; 
padding: 10px 10px; 
text-decoration: none; 
} 

.navbar li:hover, a:hover { 
background-color: #54879D; 
} 

.navbar li ul { 
display: none; 
height: auto; 
margin: 0; 
padding: 0; 
position:absolute; 
} 

.navbar li:hover ul { 
display: block; 
} 

.navbar li ul li { 
background-color: #54879D; 
float:none; 
} 

.navbar li ul li a { 
border-color: #74A3B7 #1F5065 #1F5065; 
border-left: 1px solid #1F5065; 
border-right: 1px solid #1F5065; 
border-style: solid; 
border-width: 1px; 

} 
.navbar li ul li a:hover { 
background-color: #366B82; 
} 

.lowernav{ 
height: 20px; 
border: 1px solid black; 
padding: 0; 
width: 350px; 
margin: auto; 
} 

.lowernav li { 
float: left; 
list-style: none; 
margin: 0 0; 
padding: 0; 
width:20%; 

} 

.lowernav a { 
border-right:1px solid #ffffff; 
padding: 0 10px; 
text-decoration: none; 
display: block; 
text-align: center; 

} 

.lowernav a:hover { 
color: red; 
background-color:transparent; 


} 

#copyright{ 
text-align:center; 
} 
+0

刪除線

margin: 20 0; 

也許你應該加上'顯示:block'這些新的HTML5元素(不是所有的瀏覽器理解它們)。 – Cthulhu

+0

在FF24中看起來很好 - http://jsfiddle.net/Paulie_D/WJzWD/ –

回答

1

像這樣

demo

CSS

@charset "utf-8"; 
@charset "utf-8"; 
/* CSS Document */ 
* { 
    margin: 0; 
    padding: 0; 
} 
html, body { 
    margin: 0; 
    padding: 0; 
} 
#container { 
    width: 800px; 
    background-color: #00FF00; 
    border: 1px solid black; 
    z-index: -9; 
    margin: auto; 
} 
#logo { 
    background-color: #FF0033; 
    border: #000 1px; 
    width: 800px; 
    height: 200px; 
    overflow: hidden; 
} 
nav { 
    background-color: #FFF; 
    border: #000 1px; 
    width: 800px; 
    height: 30px; 
} 
section { 
    background-color: #6F3; 
    border: #000 1px; 
    width: 780px; 
    height: 400px; 
    margin: 10px; 
} 
footer { 
    background-color: #FF0; 
    border: #000 1px; 
    width: 800px; 
    height: 100px; 
} 
.navbar { 
    /*border-right: 1px solid #54879D;*/ 
    height: 40px; 
    margin: 0 0 0 0; 
    padding: 0; 
} 
.navbar ul { 
    margin: 0; 
    padding: 0; 
} 
.navbar li { 
    background-color: #366B82; 
    float: left; 
    font: bold 12px/1.2em Arial, Verdana, Helvetica; 
    height: auto; 
    list-style: none outside none; 
    margin: 20 0; 
    padding: 0; 
    text-align: center; 
    width: 160px; 
} 
.navbar a { 
    /* border-left: 1px solid #54879D;*/ 
    border-right: 1px solid #1F5065; 
    color: #FFFFFF; 
    display: block; 
    padding: 10px 10px; 
    text-decoration: none; 
} 
.navbar li:hover, a:hover { 
    background-color: #54879D; 
} 
.navbar li ul { 
    display: none; 
    height: auto; 
    margin: 0; 
    padding: 0; 
    position: absolute; 
} 
.navbar li:hover ul { 
    display: block; 
} 
.navbar li ul li { 
    background-color: #54879D; 
    float: none; 
} 
.navbar li ul li a { 
    border-color: #74A3B7 #1F5065 #1F5065; 
    border-left: 1px solid #1F5065; 
    border-right: 1px solid #1F5065; 
    border-style: solid; 
    border-width: 1px; 
} 
.navbar li ul li a:hover { 
    background-color: #366B82; 
} 
.lowernav { 
    height: 20px; 
    border: 1px solid black; 
    padding: 0; 
    width: 350px; 
    margin: auto; 
} 
.lowernav li { 
    float: left; 
    list-style: none; 
    margin: 0 0; 
    padding: 0; 
    width: 20%; 
} 
.lowernav a { 
    border-right: 1px solid #ffffff; 
    padding: 0 10px; 
    text-decoration: none; 
    display: block; 
    text-align: center; 
} 
.lowernav a:hover { 
    color: red; 
    background-color: transparent; 
} 
#copyright { 
    text-align: center; 
} 
footer p { 
    margin: 0; 
    padding: 0; 
}/* CSS Document */ 
+0

感謝您的關注,但我仍然在Firefox中遇到問題 – LeDoc

0

.navbar li 
+0

謝謝!這工作完美! – LeDoc