Jump to content

DIV Top Right Corner


barkster

Recommended Posts

this doesn't work in ie6 or less

 

you can use css....

 

div#topright

{

position: fixed;

top: 0;

right: 0;

}

 

or if you don't mind javascript doing it....

 

immediately after the closing div tag

 

put this code

...
</div>
<script type="text/javascript">
keepVisible('topright');
</script>

 

(assuming the div you want in the top right has an id of topright!!!! - chnage that accordingly.)

 

then in the head section of the page

<script type="text/javascript">

keepVisible	=	function (id)
{
var	el				=	document.getElementById(id);
var	getScrollTop	=	function()
{
	return document.body.scrollTop||document.documentElement.scrollTop
};
el.keepInView	=	function()
{
	var target	=	getScrollTop();	
	var curY		=	el.offsetTop;

	var curY	=	el.offsetTop;
	var newY	=	null;
	target		=	0;
	newY	=	curY + ((target - curY)/20);
	newY	=	Math.ceil(newY);
	if	(
		newY	==	null
		)
	{
		newY	=	target;
	}
	el.style.top	=	newY + 'px';
}
setInterval('document.getElementById("' + id + '").keepInView()',10);
}
</script>

 

that will kind of slide it in if you want it to just move immediately then set newy = curY.

Link to comment
https://forums.phpfreaks.com/topic/55156-div-top-right-corner/#findComment-272667
Share on other sites

its an add on in ff.

 

tools > add ons then click the get extensions link in the bottom right of the popup.

 

search the developer tools for console2 (the 2 is superscript).

 

if you spend a bit of time on those pages you will find other little treasures like the 'web developer' toolbar, css view total validator and so on...

 

have fun.

 

PS is this page live? if you send a link I'll have a look at why the js i sent aint working.

Link to comment
https://forums.phpfreaks.com/topic/55156-div-top-right-corner/#findComment-273248
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.