Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-07-2012, 02:21 PM   PM User | #1
joelbrandman
New Coder

 
Join Date: Aug 2012
Posts: 10
Thanks: 4
Thanked 0 Times in 0 Posts
joelbrandman is an unknown quantity at this point
How to set up a div so it follows the scroll when scrolling down a browser

Hi,

Can someone help me recreate how to make this effect seen in this example?
http://kerrynehil.com/work/hot-studio/

I want to be able to set up a left side Div which stays at the top of the browser when scrolling down. I also want to re create the smooth follow seen on the above example website that i provided.

Any help will be very grateful!

Thank you.
joelbrandman is offline   Reply With Quote
Old 09-07-2012, 03:41 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 950
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
Set the position of the div to "fixed" and then set the top and left to wherever you want.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is online now   Reply With Quote
Old 09-07-2012, 08:42 PM   PM User | #3
jkurrle
New Coder

 
Join Date: Jan 2012
Posts: 41
Thanks: 21
Thanked 1 Time in 1 Post
jkurrle is an unknown quantity at this point
This is better handled with CSS

As WolfShade noted, set the positioning to fixed and set specific coordinates for margin-top and margin-left. What he didn't mention is that this is done normally through CSS. Here is a floating div declaration in the CSS file of a project I'm working on:
Code:
.overlay div 
  {
  position: fixed;
  width:400px;
  height: 300px;
  top: 20%;
  left:50%;
  margin-left: -200px;
  margin-top: -150px;
  background-color: #fff;
  border:1px solid #000;
  padding:15px;
  text-align:center;
  }
While you can adjust CSS properties with javascript, if this div is going to be constantly on the page, you'd be better off declaring the div style in your CSS file.
jkurrle is offline   Reply With Quote
Users who have thanked jkurrle for this post:
joelbrandman (09-10-2012)
Reply

Bookmarks

Tags
css, div, javascript, jquery

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:38 PM.


Advertisement
Log in to turn off these ads.