为什么我的文字超链接

时间:2013-11-18 10:09:02

标签: html css html5 hyperlink

这是我的HTML代码:

<!DOCTYPE html>
<html lang="en">
<head>
<title>A+Tec</title>
<style type="text/css" >
* {
  margin: 0px;
  padding: 0px;

}
#wrapper {
  width: 100%;
  height: auto;
  background-color: #ABEBC1;
  position: fixed;
}

#nav {
  width: 1400px;
  height: auto;
  margin: auto;
}

#main {
background-color: #87CEEB;
width: 100%;
height: 100%;
}

#logo {
width: 261px;
height:163px;
position:fixed;
background-color: none;
background-image:url('logo.png');
right:0px;
max-height:100%;
max-width:100%;
background-color: #87CEEB;
}


.buttons {
  width: 200px;
  background-color: #ABEBC1;
  background-repeat: repeat-x;
  float: left;
  margin: 0px 10px;
  text-align: center;
  font-family:"Arial Rounded MT Bold", Arial, Helvetica, sans-serif;
}
</style>
</head>

<body>

<div id="logo">
hello
</div>

<div id="wrapper">
  <div id="nav">
  <div class="buttons">
  </div>
  <div class="buttons"><a href="#aboutus" class=buttons>About Us</a></div>
  <div class="buttons"><a href="#ourstaff" class=buttons>Our Staff</div>
  <div class="buttons"><a href="#newadmissions" class=buttons>New Admissions</div>
  <div class="buttons"><a href="#alevel" class=buttons>A-Level</div>
  <div class="buttons"><a href="#gcse" class=buttons>GCSE</div>
  <div class="buttons"><a href="#contactus" class=buttons>Contact Us</div>
  </div>
</div>
<br/>

<div id="main">
<h3 id="aboutus"><br/></h3>
<p>This chapter explains ba bla bla</p>

<h3 id="ourstaff"><br/></h3>
<p>This chapter explains ba bla bla</p>

<h3 id="newadmissions"><br/></h3>
<p>This chapter explains ba bla bla</p>

<h3 id="alevel"><br/></h3>
<p>This chapter explains ba bla bla</p>

<h3 id="gcse"><br/></h3>
<p>This chapter explains ba bla bla</p>

<h3 id="contactus"><br/></h3>
<p>This chapter explains ba bla bla</p>
</div>

</body>
</html>

我的代码也在http://jsfiddle.net/D4fRQ/。我没有指定主要文本“本章解释bla bla bla”是一个超链接,但它是一个超链接。这是为什么?

4 个答案:

答案 0 :(得分:2)

必须正确关闭所有锚标记。

<div class="buttons"><a href="#contactus" class=buttons>Contact Us</a></div>

您错过了上述行中的</a>。和其他人一样。

答案 1 :(得分:0)

您不会关闭按钮控制节点中的任何元素。

答案 2 :(得分:0)

<div class="buttons"><a href="#contactus" class=buttons>Contact Us</div>

没有关闭</a>代码?

答案 3 :(得分:0)

你的div应该是这样的:

  <div class="buttons"><a href="#aboutus" class=buttons>About Us</a></div>
  <div class="buttons"><a href="#ourstaff" class=buttons>Our Staff</a></div>
  <div class="buttons"><a href="#newadmissions" class=buttons>New Admissions</a></div>
  <div class="buttons"><a href="#alevel" class=buttons>A-Level</a></div>
  <div class="buttons"><a href="#gcse" class=buttons>GCSE</a></div>
  <div class="buttons"><a href="#contactus" class=buttons>Contact Us</a></div>