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

Thread: Layer on top

  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Layer on top

    Hi,
    I have a simple horizontal menu I created. Is there any way to set it up so it stays at the top when the user scrolls? My client would like this feature and I am little new to dhtml and don't know where to start.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Common approach is to use frames.

    You can make a "content" division with
    position: absolute;
    overflow: scroll;
    and resize it every time the browser window is resized so it stays
    within the client window.

    Once M$ gets their, you know what, together and makes a CSS2 compliant browser the answer would be
    position: fixed
    Last edited by Vladdy; 07-03-2002 at 03:47 PM.
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just out of curiousity how would I get it to work in some browsers? just add that style to the layer?

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Alternate method:

    <html>
    <head>
    <title>untitled</title>
    <style type="text/css">

    #menu {
    font: 800 36px monospace;
    background: sienna;
    border: 3px tan double;
    }

    #container {
    position: relative;
    top: 0px;
    }

    </style>
    <script type="text/javascript" language="JavaScript">

    var menu_el = null;
    var menu_offset = 0; //distance from page top - match to #container top: (CSS)

    function getEl(id) {
    return document.all ? document.all(id) :
    document.getElementById ? document.getElementById(id) :
    document.layers ? document.layers[id] : null;
    }

    function moveToY(el) {
    if (typeof document.all != 'undefined')
    el.style.top = parseInt(document.body.scrollTop) + menu_offset;
    else if (typeof document.getElementById != 'undefined' &&
    typeof window.pageYOffset != 'undefined')
    el.style.top = pageYOffset + menu_offset;
    else if (el.pageY) el.pageY = pageYOffset + menu_offset;
    }

    function menu_static() {
    menu_el = getEl('container');
    if (typeof window.onscroll != 'undefined' && menu_el)
    onscroll = function() {
    moveToY(menu_el);
    }
    else if (document.layers) setInterval('moveToY(menu_el)',10);
    }

    onload = menu_static;

    </script>
    </head>
    <body>
    <div align="center">
    <div id="container">
    <span id="menu">||||||||||||||||||||||||</span>
    </div>
    _____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>
    _____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>
    _____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>
    _____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>
    _____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>
    _____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>_____<br>
    </div>
    </body>
    </html>


  •  

    Posting Permissions

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