I have a question regarding the anchor tag.
I have a page like
<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>
My css
#header{
position: fixed;
right: 0;
left: 0;
z-index: 1030;
margin-bottom: 0
height: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!
Here is a really odd way of doing it...
Suppose this is your HTML, place the anchor (no content!) right before the element of interest:
And apply this CSS:
See demo at: http://jsfiddle.net/audetwebdesign/6gHE6/
The trick involves using the
:target
selector to add a margin to the bottom of the anchor equivalent to the height of the fixed header.This generates some extra white space in your page, oh well... like I said, a bit of an odd way of doing it.
Alternatively, a JavaScript/jQuery fix might be the ticket!
I would try:
to force all your content to always be below the header.
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: 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).
Hi maybe this should do the trick
and
Edit :
Or with anchor like this