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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.