Solved

Using a script to adjust div positioning

Posted on 2007-04-10
2
404 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now