SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: slide div

  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    slide div

    Hello, I have a div with an image in it, without text. I would like to make the div slide from position:relative; left:300px backwards to left:10px OnLoad...

    I have looked around at different slide options online and it looks like all seem too complicated for this simple task. Does anyone know the js to make my "slideout" id move horizontally to the left?

    Thanks in advance

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    You perform such moves by adjusting the CSS properties of the element.

    To animate a slide in javascript you need to use setTimeout or setInterval, so that on a certain time interval (such as 30 milliseconds) you can adjust the left property of the element so that it's closer to where you want it to be.

    Yes, the process can be complicated, which is why some libraries include animation methods to help simplify the development process.

    Do you have a code library in mind for this, such as jQuery or YUI?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Paul, I know very little js, and a little jquery. I would assume either library, as long as it works cross-browser. Where can I find a tutorial on this specific setup? Thanks

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    The jQuery's animate page has the details you should need.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. Checking into it now...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •