Solved

Using a script to adjust div positioning

Posted on 2007-04-10
2
407 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

803 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