如何解决我的锚点链接问题 [英] How to fix my anchor link issue

查看:164
本文介绍了如何解决我的锚点链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于锚标签的问题。

I have a question regarding the anchor tag.

我有一个页面

<div id='header'>
    bunch of stuff….and iamges
</div>

<div>
   <a href='#test1>test1</a>
   <a href='#test2>test2</a>
   <a href='#test3>test3</a>
</div>

<div class='content'>
   <a name='test1'>test1 project</a>
   bunch of stuff

   <a name='test2'>test1 project</a>
   bunch of stuff

   <a name='test3'>test1 project</a>
   bunch of stuff
</div>

我的css

#header{
  position: fixed;
  right: 0;
  left: 0; 
  z-index: 1030;
  margin-bottom: 0
 height:150px;
}



< contents'div推到我的头div的顶部。
所以我的'content'div覆盖我的头div(150px)。有没有解决我的问题?非常感谢!

However, it seems like every time I click test1 to test3 link, my 'contents' div got push to top of my header div. so my 'content' div is cover by my header div (150px). Are there anyways to fix my issue? Thanks a lot!

推荐答案

将z-index参数设置为-1。拥有它一个高价值他把你的div在其他人,将浮在其他人。-1将设置在z排序少于trhe其他人。

Set z-index parameter to -1. Having it with a high value his puts your div over the others and will be floated over the others.-1 Will set it in a z-ordering less than trhe others. You can also remove it completely if you don't care about specific z-ordering betheen divs in code.

UPDATE:固定位置也会导致你的div被锚定 在页面的地方,并且扩展而不using其他。另请考虑更改CSS位置元素值( http://www.w3schools.com/css/css_positioning。 asp )。

UPDATE: Fixed position will also cause your div to be "anchored" in a place of the page, and be expanded without "pusing" the others. Please also consider changing CSS position element value (http://www.w3schools.com/css/css_positioning.asp).

这篇关于如何解决我的锚点链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆