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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    189
    Thanks
    38
    Thanked 3 Times in 3 Posts

    absolute positioning causing list items to overlap

    Hey all,

    absolute positioning is causing the list items (which contain buttons) to overlap, so the buttons are now stacked on top of each other. What I really want is the buttons to sit next to each other, but display:inline is not working with the absolute positioning:
    Code:
    <style type="text/css">
    <!--
    #page_container {
    	width: 980px;
    	background: url(bg-tile.png) repeat-y;
    	background-color: #fff;
    }
    
    #page_container h2 {
    	background: url(bg-top.png) no-repeat left top;
    	padding-top: 200px;
    }
    
    #page_container .last {
    	background: url(bg-bottom.png) no-repeat left bottom;
    	padding-top: 10px;
    	padding-bottom: 10px;
    	color: #fff;
    }
    
    #page_container h2, #page_container .last, p {
    	padding-left: 20px;
    	padding-right: 20px;
    } 
    
    #navlinks ul {
    	position: relative;
    }
    
    #navlinks li {
    	display: inline;
    	position: absolute; top:120px;
    	float: left;
    }
    
    -->
    </style>
    
    <body>
    <div id="navlinks">
    <ul>
    <li><img src="l-button.png" /></li>
    <li><img src="md-button.png" /></li>
    <li><img src="r-button.png" /></li>
    </ul>
    </div>
    <div id="page_container">
    <h2>Welcome</h2>
    <p>RoR home; full stack, Web application framework optimized for sustainable programming productivity, allows writing sound code by favoring convention over RoR home; full stack, Web application framework optimized for sustainable programming productivity, allows writing sound code by favoring convention over RoR home; full stack, Web application framework optimized for sustainable programming productivity, allows writing sound code by favoring convention over RoR home; full stack, Web application framework optimized for sustainable programming productivity, allows writing sound code by favoring convention over </p>
    <p class="last">Copyright</p>
    </div>
    </body>
    Any advice would be greatly appreciated!

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello johnmerlino,
    When you ap your li items top:120px; they assume left:0;
    You will either need to give each li an id/class and postion it top and left or, even better, don't use ap at all.

    Lots of menu examples here.


    .
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    johnmerlino (11-19-2009)

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Posts
    189
    Thanks
    38
    Thanked 3 Times in 3 Posts
    If I don't apply absolute positioning, then the relative positioning pushes the entire div container down from the top of the page.

  • #4
    Senior Coder
    Join Date
    Oct 2005
    Posts
    1,340
    Thanks
    0
    Thanked 61 Times in 60 Posts
    Then display the ul absolutely but remove ap from the li

  • Users who have thanked drhowarddrfine for this post:

    johnmerlino (11-19-2009)

  • #5
    Regular Coder
    Join Date
    Oct 2009
    Posts
    189
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Hey all,

    Well, there is a problem when I apply the absolute positioning to the ul and remove it from the li. When I resize the screen, everything adjusts, but the list elements remain fixed to the page because the parent is now the body. I would like the list to resize along with the rest of the page when resizing the screen. Thanks for all your advice.

  • #6
    Regular Coder
    Join Date
    Oct 2009
    Posts
    189
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Nevermind, I just added a div around it to constrain it in place. Thanks for your replies.

  • #7
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Quote Originally Posted by johnmerlino View Post
    Hey all,

    Well, there is a problem when I apply the absolute positioning to the ul and remove it from the li. When I resize the screen, everything adjusts, but the list elements remain fixed to the page because the parent is now the body. I would like the list to resize along with the rest of the page when resizing the screen. Thanks for all your advice.
    I'm still going with my original suggestion that ap is not needed here. Did you look at those menu examples I linked you to?

    If you still have your ul inside #navlinks like the code you originally posted, making #navlinks position relative will make your #navlinks ul take it's position from #navlinks. Did that make any sense at all?
    Like this -
    Code:
    #navlinks {
    	position: relative;
    }
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

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