Jump to content

Trying to position a <div> to stay in corner even when scrolling


music_lp90

Recommended Posts

Hi, I have a <div> that I would like to be positioned in the bottom right corner of the screen. I've tried using css position:absolute, but that only keeps it positioned there when someone resizes the window. I would like it to stay in the corner even when the user scrolls down the page.Here's the code if it helps at all:

<script type="text/javascript" language="javascript">function countDown(){	var months			= new Array("January", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")	var rightNow 		= new Date();	var hours 			= rightNow.getHours();	var mins 			= rightNow.getMinutes();	var sec				= rightNow.getSeconds();	var year			= rightNow.getFullYear();	var month			= rightNow.getMonth() + 1;	var day				= rightNow.getDate();	var daysInMonth 	= 32 - new Date(year, month -1, 32).getDate();	var daysLeftinMonth = daysInMonth - day;	var targetDate  	= new Date("March 31, 2008 23:59:59");	var targetMonth		= targetDate.getMonth() + 1;	var am_pm			= "AM";	var variableMonth 	= new Date();	var variabledaysInMonth=0;	var daysUntilExpire; //Calculated below counts how many days from now until the expiration date	var hoursUntilExpire;	var secondsInADay	= 24*60*60;		for (var i = month; i < targetMonth-1; i++){		if (i < 10){			i = "0" + i;		}		variabledaysInMonth += 32 - new Date(year, i, 32).getDate();	}	//EXPIRATION CALCULATIONS	daysUntilExpire = variabledaysInMonth + daysLeftinMonth + targetDate.getDate() - 2;	var secondsInFullDays = daysUntilExpire*24*60*60;	var secondsToday 	= (hours*60*60) + mins*60 + sec;	var secondsLeft 	= secondsInADay - secondsToday + secondsInFullDays;	var countDays 		= Math.floor(secondsLeft/60/60/24);	var countHours 		= Math.floor((secondsLeft - countDays*secondsInADay)/60/60);	var countMins		= Math.floor((secondsLeft - (countDays*secondsInADay + countHours*60*60))/60);	var countSeconds	= secondsLeft - (countDays*secondsInADay + countHours*60*60 + countMins*60);	//Time conversions	if (hours > 12){		hours-=12;		am_pm = "PM";	}	if (mins < 10){		mins = "0" + mins;	}	if (countSeconds < 10){		countSeconds = "0" + countSeconds;	}	document.getElementById("displayClock").innerHTML = countDays + " days " + countHours + " hours " + countMins + " minutes " + countSeconds + " seconds";}var int=self.setInterval("countDown()", 50);</script><script language="javascript" type="text/javascript">function closeCountdown(){	document.getElementById("show").innerHTML = "";}</script><!--Hide or show Div --><div id="show">	<!-- CONTAIN AND POSITION -->	<div  id="containCount" style="width: 254px; position:absolute; bottom: 10px; right: 10px; font-size:10px; ">		<div style=" width: 254px; text-align:center;"><a href="java script:closeCountdown()" style="color:#000000; font-size: 12px; padding: 0px; margin: 0px; text-decoration:underline;">Close</a></div>		<div id="containCountBody" style="width: 254px; background-color: #333300;">			<div id="displayClock" style="width:250px; text-align: center; background-color: #333300;">				</div>			<a href="java script:closeCountdown()"><img src="http://localhost/images/stories/PresSaleAd.jpg" border="0" style="padding: 0px 0px 2px 2px; "></a>					</div>	</div></div>

Thanks!

Link to comment
Share on other sites

Thanks, I just made a quick test page and that seems to work, but I can't test it out on the project until monday. I read up a little on it and it seems that the browser support for position:fixed is not that good, though. If the support isn't good for it, I was thinking that maybe javascript could position it using x,y coordinates or something, but I'm not sure if thats possible or how to do it.Thanks again!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...