码迷,mamicode.com
首页 > Web开发 > 详细

a标签中href="#xxx"跳到id="xxx"

时间:2014-10-29 16:38:08      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   ar   sp   div   on   2014   

HTML中a标签中href="#xxx",当点击后,页面会跳转到标签中id="xxx"的地方。
同时,在URL上的后面会看到加上了#xxx,这样直接改变URL中#后面的值,然后页面就可以跳转到标签中id为这个值的地方。
bubuko.com,布布扣
 bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣
测试代码:
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
<style>
p{
    height:700px;
}
</style>
</head>
<body>
    <a href="#xxx">tab1</a>
    <a href="#b">tab2</a>
    <a href="#c">tab3</a>

    <p>pp<em>pppp</em>pp</p>
    <h2 id="xxx">tag1</h2>
    <p>111111111</p>
    <h2 id="b">tag2</h2>
    <p>111111111</p>
    <h2 id="c">tag3</h2>
    <p>111111111</p>
</body>
</html>

 

a标签中href="#xxx"跳到id="xxx"

标签:style   blog   http   color   ar   sp   div   on   2014   

原文地址:http://www.cnblogs.com/ayguo/p/4059630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!