Solved

Using a script to adjust div positioning

Posted on 2007-04-10
2
411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

617 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