SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Location
    London, U.K.
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Anchor problems! Help please..

    Hi...

    I'm having a problem with my anchors not going to the right place. I have my anchors positioned at the begining of a section in my document. But rather than the content from the top of the section being displayed it shows a bit of the section above as well.

    I'm quite new to all this so hope I'm making sense and that its not simply a problem with my coding.

    I hope someone can help me out with this.

    Thanks for your time.

    Ayesha

    http://ayesha.webeyedea.info/naqsha

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,139
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    tags

    Hi naqsha, welcome to the forums,
    Years back, the only thing that could have target anchors were anchor tags. Now anything can be targetted. So, in your code eg.
    HTML Code:
    <a name="graphic"></a>
    	
    	<!--nav menu for ie-->
    	<div id="nav2">
    	    <ul>
    	
    			
    			<li> <a href="#portfolio" target="_self"> Portfolio </a> </li>
    
    			<li> <a href="#about" target="_self"> About </a> </li>
    			<li> <a href="#top" target="_self"> <img src="images/home.gif" alt="home" title="home" height="18" width="18" /> </a> </li>
    			<li> <a href="#contact" target="_self"> Contact </a> </li>
    
    			<li> <a href="#links" target="_self"> Links </a> </li>
    	
        </div>
    	
    	<img src="images/graphic.gif" alt="graphic design portfolio" title="graphic design portfolio" height="121" width="600" />
    				
    	<div id="graphic">
    you intend the link to go to
    HTML Code:
    <a name="graphic"></a>
    but the browser is going to the last instance of that name which is
    HTML Code:
    <div id="graphic">
    If you rename one or the other you should be fine.

  3. #3
    SitePoint Member
    Join Date
    Jun 2006
    Location
    London, U.K.
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mitteneague...

    Thanks a lot for the reply...

    I just tried making the tag names different to those of the divs but I'm still having the problem I had before.

    I have a back to top button in a div just before the anchor tag, with the section content following the anchor. When I click the link to the anchor it shows me the page from the back to top div and not from the anchor downwards. As in, the back to top button is right on top of the screen when what I want is the header image to be at the top.

    One of the reasons I wanted to fix this is because I have a fixed nav bar (for browsers other thn IE ) and I didnt want the back to top button stuck up there!

    Any suggestions for this would be much appreaciated.

    Thanks
    Ayesha.

  4. #4
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try puttin the anchor/id="name" within the <h1> tag. see how that goes.

  5. #5
    SitePoint Member
    Join Date
    Jun 2006
    Location
    London, U.K.
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for ur suggestion belledumonde

    <h1> <a name="contact"></a> </h1>

    is that what u meant...(sorry if i seem ignorant)

    coz i tried that and it doesnt work...
    Last edited by naqsha; Jun 11, 2006 at 06:38.

  6. #6
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can also ad the id to the h1 tag <h1 id="whatever"></h1> (i think.... )

    hm... maybe its got to do with the browser? coz sometimes when i use anchors, in firefox, there really is some space above it, and in IE, there isnt any.

    what about placing the anchor lower in the design? like in the text or something? then the extra space will show the title instead of whats above the title??

  7. #7
    SitePoint Member
    Join Date
    Jun 2006
    Location
    London, U.K.
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help belledumonde...

    I'll try moving the anchor around to get it to work right.

    I thought there might be something wrong with my coding which was making it act funny!

  8. #8
    Carpe Diem = Fish of the Day fisherboy's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi naqsha.

    Can't get your page to open?
    fisherboy
    Web Site Design

  9. #9
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey naqsha! been looking at some of your other sites, id just like to say, i really like your designs. everything is clean and easy. how do you do it? hehe!

  10. #10
    SitePoint Member
    Join Date
    Jun 2006
    Location
    London, U.K.
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi fisherboy...The prob was that the link to the anchor isnt skipping to where I want it to on the page but showing extra content on top. The link to the first section is fine but the other links show the back to top button of the previous section as well. *sigh*

    Glad you liked my sites belledumonde.... I'm just starting out with web design. Hopefully other people will like them enough to give me some work.

  11. #11
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you might just be starting out with web development and design, but your design skills translate really well on screen. have you been able to fix the anchor problem yet? tried moving the anchor a little further down the page?

  12. #12
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,139
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    ids

    The problem may have something to do with using id instead of class.
    Id is for a uniquely named element. Class can be used for more than one.
    You have more than one <div id="back_top">, <div id="nav2">, and<div id="thn">.

  13. #13
    SitePoint Member
    Join Date
    Jun 2006
    Location
    London, U.K.
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Belledumonde - I did try moving the anchor around. I originally had it above the section header. When I put it below the header, it decides to work right and shows me content just below the anchor point!!

    Mitteneaque - I havent tried making the divs used more than once into classes yet. Will give that a try. Thanks for the suggestion.

  14. #14
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello again! i just noticed something, it doesnt work in IE. i mean, not the way i think you want it to work -- which is the way it works in FF. the menu isnt fixed at the top. but then you might have changed this aspect, in which case just ignore this message.

  15. #15
    SitePoint Member
    Join Date
    Jun 2006
    Location
    London, U.K.
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehehe.... position: fixed; doesnt work in IE thats why I have the menu repeating at the top of every section and I've hidden it in all other 'good' browsers.

  16. #16
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    reeeeeeeally? had no idea! IE sucks, had no idea how much till the person who reprogrammed by computer included FF.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •