PDA

View Full Version : Sliding Button


Caoctane
04-21-2007, 03:06 PM
New to the forum, and so far it seems pretty damned good, already had 2 questions I WAS going to ask answered...search function :)
But.....
I want to add a button or a picture to my webpage that when the user scrolls down stays with the user and does not disappear off screen.

You may have seen this on other web pages, I know I have seen it done many times before, but I can't seem to find any websites with the feature to show as an example....

But just to clarify,



----------------------------------------------------- A


-__-__-__- B

If line A is the top of a page, and B is the button, when B reaches the top of the page(A) it will be "pushed" down the page as it scrolls, so the button will always be seen. It would be even better if button B could stay where it is, so for example, if it was 5 lines from the top of the page it would scroll with the page but always be 5 lines from the top.

I hope this is clear enough for me to get some help, if not just say so and I'll try to find an example of some sort.

Quick note: I am not sure if this is CSS or can be done with HTML, or is Java or whatever so I posted here.. Sos if wrong.

edbr
04-23-2007, 01:36 AM
Would this help.
this will put a fixed division on your page.

#div{
position: fixed;
left: 10px;
top: 50px;
}

davidj
04-23-2007, 05:50 AM
i think Caoctane wants a element that follows the scrolling

i.e. Not Fixed

edbr
04-23-2007, 06:17 AM
OK I wasnt sure

I want to add a button or a picture to my webpage that when the user scrolls down stays with the user and does not disappear off screen.

if the button or image is in the div it will stay in place while the rest can scroll

Caoctane
04-23-2007, 05:21 PM
Where abouts in the code would I put this? I have lots of stuff written before and after the img src part....

will it be #div{img src=imagenameblba.jpg
position: fixed;
left: 10px;
top: 50px;
}

I dont know THAT much about code, as I pretty much create my web pages in photoshop slice and import, i do minimal coding.

davidj
04-23-2007, 06:07 PM
this wont do what your after

you need some DHTML

I have seen what you want but cant remember where

I will have a think

Caoctane
04-23-2007, 06:32 PM
Thanks, its not massively urget, or integral to the site, but if I could add it it'd make it look sleeker :)

edbr
04-24-2007, 12:52 AM
have alok here
http://www.javascriptkit.com/dhtmltutors/fixedcontent.shtml

davidj
04-24-2007, 12:57 AM
edbr

i eat my hat

thats it but seen the position fixed so thought it was "fixed into position"

ill keep away from CSS Q's from now on and leave it to the experts

Caoctane
04-24-2007, 01:54 PM
Ok thanks, Ill give that code a go. I was putting it in the web page iteself, not in the .css file which shows you how much I know about CSS lol.

One more question, whats the CSS code for centering a page. Searching there seems to be lots of different ones, so which one do I use?