Current location: Hot Scripts Forums » General Web Coding » CSS » Moving division


Moving division

Reply
  #1 (permalink)  
Old 03-19-09, 04:24 AM
chiragkhunti chiragkhunti is offline
New Member
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Moving division

Hello friends,

Need ur quick help here..

i m developing a consultancy website, in which i m having list of services. there are 12 services, all 12 services having different static htm pages for it's detail. and i have put list of all service to the left side of page to navigate through any service.

till here it is working fine. but now i want to move that left side list of services along with page scrolling. i.e. if the page scrolls down then the service list should also move downwards so that the navigation becomes very easy....

does anyone having any idea abt this...... i know it can be done but how that is big question?
Reply With Quote
  #2 (permalink)  
Old 03-19-09, 04:40 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
Topic moved to the CSS forum.

Have you tried setting the "position" to "static" ?
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 03-19-09, 04:54 AM
chiragkhunti chiragkhunti is offline
New Member
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
yes, i tried it but not working like i want.... it is just sticking to one place in static position. when i scroll down it is not coming down.....
Reply With Quote
  #4 (permalink)  
Old 03-19-09, 05:37 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
You could try something like "Fixed & Sticky Menu".
http://www.jtricks.com/javascript/na...ixed_menu.html
__________________
Jerry Broughton
Reply With Quote
  #5 (permalink)  
Old 03-19-09, 06:28 AM
chiragkhunti chiragkhunti is offline
New Member
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
still not working..

i have done all things from ur given reference link but still not working. will the given example work in html page?
Reply With Quote
  #6 (permalink)  
Old 03-19-09, 12:47 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Look, here is a very simple example using the "Sticky Menu".
I have modified it slightly so the bulk of the Javascript will be in the HEAD element.

The "Sticky Menu" div has the id "menu_container".
Put your menu inside that div.

The div with the id "menu_spacer" and the div with the class "menu_container" are used to reserve space for the "Sticky Menu".

There is more documentation in the code.

Javascript Code:
  1. <html>
  2. <head>
  3. <script>
  4. var fixedMenuId;
  5. var fixedMenu;
  6. function stickit(obj)
  7. {
  8.  fixedMenuId = obj;
  9.  fixedMenu =
  10.    {
  11.        hasInner: typeof(window.innerWidth) == 'number',
  12.        hasElement: document.documentElement != null
  13.           && document.documentElement.clientWidth,
  14.  
  15.        menu: document.getElementById
  16.            ? document.getElementById(fixedMenuId)
  17.            : document.all
  18.              ? document.all[fixedMenuId]
  19.              : document.layers[fixedMenuId]
  20.    };
  21.    stickit_1();
  22.    }
  23.   function stickit_1()
  24.   {
  25.     /* Script by: [url]www.jtricks.com[/url]
  26.      * Version: 20071127
  27.      * Latest version:
  28.      * [url]www.jtricks.com/javascript/navigation/fixed_menu.html[/url]
  29.      */
  30.  
  31.  
  32.  
  33.  
  34.    fixedMenu.computeShifts = function()
  35.    {
  36.        fixedMenu.shiftX = fixedMenu.hasInner
  37.            ? pageXOffset
  38.            : fixedMenu.hasElement
  39.              ? document.documentElement.scrollLeft
  40.              : document.body.scrollLeft;
  41.        if (fixedMenu.targetLeft > 0)
  42.            fixedMenu.shiftX += fixedMenu.targetLeft;
  43.        else
  44.        {
  45.            fixedMenu.shiftX +=
  46.                (fixedMenu.hasElement
  47.                  ? document.documentElement.clientWidth
  48.                  : fixedMenu.hasInner
  49.                    ? window.innerWidth - 20
  50.                    : document.body.clientWidth)
  51.                - fixedMenu.targetRight
  52.                - fixedMenu.menu.offsetWidth;
  53.        }
  54.  
  55.        fixedMenu.shiftY = fixedMenu.hasInner
  56.            ? pageYOffset
  57.            : fixedMenu.hasElement
  58.              ? document.documentElement.scrollTop
  59.              : document.body.scrollTop;
  60.        if (fixedMenu.targetTop > 0)
  61.            fixedMenu.shiftY += fixedMenu.targetTop;
  62.        else
  63.        {
  64.            fixedMenu.shiftY +=
  65.                (fixedMenu.hasElement
  66.                ? document.documentElement.clientHeight
  67.                : fixedMenu.hasInner
  68.                  ? window.innerHeight - 20
  69.                  : document.body.clientHeight)
  70.                - fixedMenu.targetBottom
  71.                - fixedMenu.menu.offsetHeight;
  72.        }
  73.    };
  74.  
  75.    fixedMenu.moveMenu = function()
  76.    {
  77.        fixedMenu.computeShifts();
  78.  
  79.        if (fixedMenu.currentX != fixedMenu.shiftX
  80.            || fixedMenu.currentY != fixedMenu.shiftY)
  81.        {
  82.            fixedMenu.currentX = fixedMenu.shiftX;
  83.            fixedMenu.currentY = fixedMenu.shiftY;
  84.  
  85.            if (document.layers)
  86.            {
  87.                fixedMenu.menu.left = fixedMenu.currentX;
  88.                fixedMenu.menu.top = fixedMenu.currentY;
  89.            }
  90.            else
  91.            {
  92.                fixedMenu.menu.style.left = fixedMenu.currentX + 'px';
  93.                fixedMenu.menu.style.top = fixedMenu.currentY + 'px';
  94.            }
  95.        }
  96.  
  97.        fixedMenu.menu.style.right = '';
  98.        fixedMenu.menu.style.bottom = '';
  99.    };
  100.  
  101.    fixedMenu.floatMenu = function()
  102.    {
  103.        fixedMenu.moveMenu();
  104.        setTimeout('fixedMenu.floatMenu()', 20);
  105.    };
  106.  
  107.    // addEvent designed by Aaron Moore
  108.    fixedMenu.addEvent = function(element, listener, handler)
  109.    {
  110.        if(typeof element[listener] != 'function' ||
  111.           typeof element[listener + '_num'] == 'undefined')
  112.       {
  113.           element[listener + '_num'] = 0;
  114.           if (typeof element[listener] == 'function')
  115.           {
  116.               element[listener + 0] = element[listener];
  117.               element[listener + '_num']++;
  118.           }
  119.           element[listener] = function(e)
  120.           {
  121.               var r = true;
  122.               e = (e) ? e : window.event;
  123.               for(var i = 0; i < element[listener + '_num']; i++)
  124.                   if(element[listener + i](e) === false)
  125.                       r = false;
  126.               return r;
  127.           }
  128.       }
  129.  
  130.       //if handler is not already stored, assign it
  131.       for(var i = 0; i < element[listener + '_num']; i++)
  132.           if(element[listener + i] == handler)
  133.               return;
  134.       element[listener + element[listener + '_num']] = handler;
  135.       element[listener + '_num']++;
  136.   };
  137.  
  138.   fixedMenu.supportsFixed = function()
  139.   {
  140.       var testDiv = document.createElement("div");
  141.       testDiv.id = "testingPositionFixed";
  142.       testDiv.style.position = "fixed";
  143.       testDiv.style.top = "0px";
  144.       testDiv.style.right = "0px";
  145.       document.body.appendChild(testDiv);
  146.       var offset = 1;
  147.       if (typeof testDiv.offsetTop == "number"
  148.           && testDiv.offsetTop != null
  149.           && testDiv.offsetTop != "undefined")
  150.       {
  151.           offset = parseInt(testDiv.offsetTop);
  152.       }
  153.       if (offset == 0)
  154.       {
  155.           return true;
  156.       }
  157.  
  158.       return false;
  159.   };
  160.  
  161.   fixedMenu.init = function()
  162.   {
  163.       if (fixedMenu.supportsFixed())
  164.           fixedMenu.menu.style.position = "fixed";
  165.       else
  166.       {
  167.           var ob =
  168.               document.layers
  169.               ? fixedMenu.menu
  170.               : fixedMenu.menu.style;
  171.  
  172.           fixedMenu.targetLeft = parseInt(ob.left);
  173.           fixedMenu.targetTop = parseInt(ob.top);
  174.           fixedMenu.targetRight = parseInt(ob.right);
  175.           fixedMenu.targetBottom = parseInt(ob.bottom);
  176.  
  177.           if (document.layers)
  178.           {
  179.               menu.left = 0;
  180.               menu.top = 0;
  181.           }
  182.           fixedMenu.addEvent(window, 'onscroll', fixedMenu.moveMenu);
  183.           fixedMenu.floatMenu();
  184.       }
  185.   };
  186.   fixedMenu.addEvent(window, 'onload', fixedMenu.init);
  187.   }
  188. </script>
  189. <style>
  190. #menu_spacer
  191. {
  192.  height:500px;
  193.  float:left;
  194.  }
  195. #menu_container
  196. {
  197.  position:absolute;
  198.  width:200px;
  199.  height:50px;
  200.  padding:16px;
  201.  background:#FFFFFF;
  202.  border:2px solid #2266AA;
  203.  }
  204. .menu_container
  205. {
  206.  width:200px;
  207.  padding:16px;
  208.  border:2px solid #fff;
  209.  }
  210. #content_container
  211. {
  212.  float:left;
  213.  padding:10px;
  214.  }
  215. </style>
  216. </head>
  217. <body>
  218.  
  219. <!-- This div used to reserve space for menu. -->
  220. <div id="menu_spacer">
  221.  
  222.  <!-- This div defines the width of the reserved space. It must match the CSS of the menu container. -->
  223.  <div class="menu_container"></div>
  224.  
  225.  <!-- This div holds the menu. -->
  226.  <div id="menu_container" style="left:10px;top:10px;">
  227.   This is a (Javascript/CSS) Fixed menu.
  228.  </div>
  229.  <script type="text/javascript">
  230.  stickit('menu_container');
  231.  </script>
  232. </div>
  233.  
  234. <!-- This div holds the main content. -->
  235. <div id="content_container">
  236.  Line 1
  237.  <br />Line 2
  238.  <br />Line 3
  239.  <br />Line 4
  240.  <br />Line 5
  241.  <br />Line 6
  242.  <br />Line 7
  243.  <br />Line 8
  244.  <br />Line 9
  245.  <br />Line 10
  246.  <br />Line 11
  247.  <br />Line 12
  248.  <br />Line 13
  249.  <br />Line 14
  250.  <br />Line 15
  251.  <br />Line 16
  252.  <br />Line 17
  253.  <br />Line 18
  254.  <br />Line 19
  255.  <br />Line 20
  256.  <br />Line 21
  257.  <br />Line 22
  258.  <br />Line 23
  259.  <br />Line 24
  260.  <br />Line 25
  261.  <br />Line 26
  262.  <br />Line 27
  263.  <br />Line 28
  264.  <br />Line 29
  265.   <br />Line 30
  266.   <br />Line 31
  267.   <br />Line 32
  268.   <br />Line 33
  269.   <br />Line 34
  270.   <br />Line 35
  271.   <br />Line 36
  272.   <br />Line 37
  273.   <br />Line 38
  274.   <br />Line 39
  275.   <br />Line 40
  276.   </div>
  277. </body>
  278. </html>
__________________
Jerry Broughton
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving letters with mouse zems Script Requests 1 09-13-08 05:32 PM
Division By Zero Help eventone PHP 6 07-04-06 04:15 PM
Warning: Division by zero brian110872 PHP 3 03-24-06 02:51 PM
Moving mysql database with content from one webhost to another caver911 PHP 1 07-11-05 05:08 AM
a moving tooltip davidklonski HTML/XHTML/XML 0 06-20-04 05:20 AM


All times are GMT -5. The time now is 02:18 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.