set style.top on div [Solved]

Simple & Dumb Question

Page 1 of 1

3 Replies - 5303 Views - Last Post: 30 November 2009 - 05:27 AM

#1 Toxicterror  Icon User is offline

  • blub

Reputation: 15
  • View blog
  • Posts: 687
  • Joined: 10-March 09

set style.top on div [Solved]

Post icon  Posted 30 November 2009 - 04:11 AM

Hi Guys

I've got a simpel and little bit dumb question, but i just couldnt find a solution for it -.-

Code
<script type="text/javascript" language="javascript">
	var height = window.innerHeight
	alert(height)
	document.getElementById("taskbar").style.top = height-30+'px'
</script>
<div class="taskbar" id="taskbar">
	Sample Text
</div>

CSS (not necessary)
.taskbar {
	background-image: url(./img/taskbar_bg.png);
	background-color: #999999;
	border: 0px;
	width: 100%;
	height: 30px;
	color: #000000;
	margin: 0px;
	padding: 0px;
	margin-left: auto;
	margin-right: auto;
}


What i actually want to achieve is, that this div calledtaskbar is at the bottom of the actual browserwindow.
At the moment it just displays underneath the last element.

I'd be thankful for any responses

Cheers,
Toxic

This post has been edited by Toxicterror: 30 November 2009 - 05:30 AM


Is This A Good Question/Topic? 0
  • +

Replies To: set style.top on div [Solved]

#2 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Re: set style.top on div [Solved]

Posted 30 November 2009 - 04:29 AM

hi,
two things:
1- add
position:absolute;



2-you're executing the script before the div is rendered, so there is no taskbar at executing time, move the script down under the div
Was This Post Helpful? 1
  • +
  • -

#3 Toxicterror  Icon User is offline

  • blub

Reputation: 15
  • View blog
  • Posts: 687
  • Joined: 10-March 09

Re: set style.top on div [Solved]

Posted 30 November 2009 - 05:24 AM

hey thanks mate it worked ;)
Was This Post Helpful? 0
  • +
  • -

#4 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Re: set style.top on div [Solved]

Posted 30 November 2009 - 05:27 AM

you're welcome :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1