Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using a script to adjust div positioning

Posted on 2007-04-10
2
Medium Priority
?
413 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 2000 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

670 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