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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Positioning a div

    I am trying to position the div 'ele' on the left edge of the containing div. If I ever get this positioning stuff figured out...

    Here's what I am trying to do.

    Code:
    <div id="container">
        <div id="div1">
                   some stuff
        </div>
         <div id="div2">
                   some stuff
        </div>
        <div id="div3">
                   some stuff
        </div>
    </div>
    
    ************** the javascript
    
    function showDiv(aDiv){
    	var ele=document.getElementById(aDiv);
    	ele.style.width=ele.clientWidth;
    	alert("Left=" + ele.clientLeft);
    	set the left position;
    	ele.style.visibility="visible";
    }
    All the divs are invisible. In another part of the page the onClick fires the javascript and passes the id of the wanted div. The wanted div should fill the container. I guess I could be using layers and changing the z-index or something, but I don't know anything about layers.

    I must become one with positioning. I will remain in meditation and the lotus position while I await enlightenment.

    Thank you.
    Scott Stewart
    Always happy to learn from pros.

  • #2
    New Coder
    Join Date
    Aug 2003
    Location
    Rhondda Cynon Taff, Wales
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You will have to use CSS' position:absolute atribute.
    Ryan Jones(sciguyryan)
    Visit us and chat at our forums - the Kidscript Forums

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Thank you.

    I have gone around the bend on this. Finally I have some control over where the div shows up. I would like to get the available clear area of the container (without scroll bars) to display my div in. I am looking a offsetHeight, offsetWidth etc. to do this. If you have any hints I would love to hear them.
    Scott Stewart
    Always happy to learn from pros.

  • #4
    New Coder
    Join Date
    Aug 2003
    Location
    Rhondda Cynon Taff, Wales
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What do you mean by offste? If you could explain then i will do my best to help.
    Ryan Jones(sciguyryan)
    Visit us and chat at our forums - the Kidscript Forums


  •  

    Posting Permissions

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