In this part of the series, we effectively carry out a project. The project deals with a web page. The aim of the project is to allow visitors to move their mouse pointer to the edge of the web page to cause a pane with a calculator or some other useful tool to scroll into the page. The visitor can do whatever they want with the tool. Then, when they click on the BODY of the page, outside the pane, the pane scrolls back into the edge. The detailed requirements of the project are in the previous part of the series.
I will not deal with the code that does the calculation in this series. I've already written an article series on how to build a web page calculator, which is currently running on Dev Articles. You can read this article to see how the calculator functions.
Identify the DIV elements above. There is one DIV element inside another one. Inside the inner DIV element you have the elements for the calculator. The inner DIV element keeps the calculator components together. These elements consist of an Input Text element, buttons and line break elements. I will not say much about these elements – you can read the article series for more details.
The inner DIV element has the ID "Calc." In its style attribute, you have “left:0px;top:0px”. If you know that your CSS left and top values will be changing (by script) it is advisable to put their initial values in the style attribute (of the element) and not in the style sheet.
The ID of the outer DIV element is "Cont." It has an onclick event attribute. Click on it and the checkRemSit() function is called. I will explain how the function operates later.
This DIV element has a style attribute. The first property here is the position property. It has the "absolute" value. The next property is the z-index property with a value of 2. The BODY element is given a z-index value of 0. With these three properties, the pane (outer DIV) will appear in a layer above the rest of the elements, everything being equal.
Still in the style attribute, the next thing you see is “left=0px;top:0px;” That is, the left position is zero pixels and the right position is zero pixels. These values will be changing by script, so it is advisable to have them in the attribute. They are like the default values.
When the pane is coming out from or going to the left edge, the script causes the left value to be zero; when it is coming out from or entering the top edge, its top value is zero. The left and top properties should be put in the style attribute. The rest of the other properties can be put in the style sheet.
The last property we have in the style attribute is the display property. Its value is “none.” With the initial value of none, you do not see the pane. When you have to see the pane, the script will change the value to “block.” The inner DIV element will then scroll within this block.