Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Anchors in CSS to link above

    I have a webpage with four divs. In between each div there is the same menu linking within the page through anchors.

    It looks like that:

    MENU a
    Content 1
    MENU b
    Content 2
    MENU c
    Content 3
    MENU d
    Content 4

    Now the menu, as I said before, it's always the same, but I noted it with a, b, c and d for better understanding.

    If I try to access Content 4 from MENU a, it's possible. But once I try to access Content 2 from MENU d, for example, I can't, because it seem the anchors in the menu can't read what it's above them in the HTML code.

    But they should work, because that's how that #up anchor works in Wordpress and PHP. A solution, please?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Please post your code or a link to your page.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Dec 2010
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Code:
                    <div id="nav_portfolio">
                    	<ul>
                            <li><a href="#thumbnail" style="color:#666">web</a></li>
                            <li><a href="#mobile">mobile</a></li>
                            <li><a href="#mockups">mock-ups</a></li>
                            <li><a href="#other">other</a></li>
                        </ul>                
                    </div>
                  		
                        
                       <div id="web">                      
                        </div>
    
                        
                    <div id="nav_portfolio">
                    	<ul>
                            <li><a href="#thumbnail">web</a></li>
                            <li><a href="#mobile" style="color:#666">mobile</a></li>
                            <li><a href="#mockups">mock-ups</a></li>
                            <li><a href="#other">other</a></li>
                        </ul>                
                    </div>
                                        
                        <div id="mobile">
                        </div>
                                           
                    <div id="nav_portfolio">
                    	<ul>
                            <li><a href="#thumbnail">web</a></li>
                            <li><a href="#mobile">mobile</a></li>
                            <li><a href="#mockups" style="color:#666">mock-ups</a></li>
                            <li><a href="#other">other</a></li>
                        </ul>                
                    </div>                    
    
                        
                        <div id="mockups">
                        </div>      
                        
                    <div id="nav_portfolio">
                    	<ul>
                            <li><a href="#thumbnail">web</a></li>
                            <li><a href="#mobile">mobile</a></li>
                            <li><a href="#mockups">mock-ups</a></li>
                            <li><a href="#other" style="color:#666">other</a></li>
                        </ul>                
                    </div>                                  
            
                        <div id="other">
                        </div>

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    <li><a href="#thumbnail">web</a></li>
    Don't you need #web instead?

    btw, you can't use the same id for multiple elements inside a document. Use class instead.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Dec 2010
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Don't you need #web instead?

    btw, you can't use the same id for multiple elements inside a document. Use class instead.
    Yes, it is #web instead of #thumbnail, I renamed the CSS Div and I forgot to rename it in HTML.

    I assume the problem is the fact that I used the same id more times inside a document, which was something I was not aware of. I thought this can be done.

    Thanks for the help!

  • #6
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.


  •  

    Posting Permissions

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