Home arrow HTML arrow Mimic Edge for HTML Magic Edges

Mimic Edge for HTML Magic Edges

In this second part of a five-part series, we will see how the inner DIV element (pane) can scroll from the top of the outer DIV element, downward. We shall also see how to make the left edge of your web page respond to events, and how the pane can scroll out of it.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
March 16, 2009
  1. · Mimic Edge for HTML Magic Edges
  2. · Scrolling from the web page edge
  3. · Basic Implementation of Magic Edge
  4. · Scrolling from the Left Edge

print this article

Mimic Edge for HTML Magic Edges
(Page 1 of 4 )

Scrolling from the Top

In this section we see how the inner DIV element can be made to scroll from the top downward. Here, instead of changing the CSS left value, we shall be changing the CSS top value. The height of the inner DIV element is 196px. So the initial top value of the inner DIV element is 196px. This value should be written as a CSS attribute to the inner DIV element and not in the style sheet. I gave the reason in the previous part of the series.

The default left value is zero pixels. So you can omit the left attribute (style). With these factors, the inner DIV element will start scrolling from the top. This is the script which will accomplish that:

<script type="text/javascript">

var y = document.getElementById('Calc').style.top;

y = parseInt(y);

var TT = self.setInterval("shiftDown()",10);

function shiftDown()


document.getElementById('Calc').style.top = y;

if (y >= 0)



//adjust position

document.getElementById('Calc').style.top = "0px"





Replace the former script with this one. Put the script below the DIV elements. The operation of this and the former scripts are the same. However, the variables and the left attribute value have changed. Instead of x, for horizontal distance, we have y. The choice of y is just to make things consistent with the Cartesian coordinate system, where horizontal distance is identified by the x variable and vertical distance is identified by the y variable.

The ID returned by the setInterval() function is now TT instead of TL. The shiftRight() function is now shiftDown(). The CSS left attribute for the inner DIV object is now "top" instead of "left." Everything else stays the same. The script is then self-explanatory.

blog comments powered by Disqus

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials