Solved

Using a script to adjust div positioning

Posted on 2007-04-10
2
408 Views
Last Modified: 2008-01-09
I have a navigation div that is positioned on my web page automatically by my server.  The placement on the page is too low, and putting negative margins in the div container wont raise it higher up on the page.  Using absolute positioning does not work either since it messes up other elements of the page that the server controls.

Is there a piece of script I can use that works on load to raise a particular div a certain number of pixels up on a page?
0
Comment
Question by:jarrodprice
2 Comments
 
LVL 5

Expert Comment

by:PhilHow
ID: 18886856
Give the div an id like say "div1" with a style of "position:relative;top:0"

then
use script:
<script type="text/javascript">
function moveDiv()
{
obj = document.getElementById('div1');
EL.style.top= "-10px";
}
onload=moveDiv;
</script>

Change the -10px to whatever value you need.
0
 
LVL 6

Accepted Solution

by:
ije earned 500 total points
ID: 18887286
haven't tested, but maybe:

window.onload = function(){
  var objNav = document.getElementById('navigation_div');
  objNav.style.marginTop = (parseInt(objNav.style.marginTop) - 10) + 'px';
}
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Diminish Pop-up  in 3 seconds 7 51
jQuery Scroll To Top 5 40
Filemaker Pro - Export to Excel as Pivot Table 5 21
Why is initialize not a function? 8 25
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to dynamically set the form action using jQuery.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question