Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:29:49+00:00 2026-06-07T12:29:49+00:00

I’m trying to make a simple horizontal slider. As it stands, I have three

  • 0

I’m trying to make a simple horizontal slider.

As it stands, I have three div’s, identical sizes, in a line. I did have jQuery to move them, but currently the viewport moves with them or nothing happens at al.
Can anyone point me in the direction so that the viewport stays fixed and the content slides across it? This is the code so far…

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Slider (cutdown, demo)</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#trigger1').click(function(){
$(".box").animate({left: "0"});
});
$('#trigger2').click(function(){
$("#viewport").animate({left: "-200"});
});
$('#trigger3').click(function(){
$(".box").animate({left: "-400"});
});
});
</script>
<style>
body    {
background:#003;
color:#FFF;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
}
#viewport   {
width:200px;
height:200px;
overflow:hidden;
}
.box    {
background-color:#069;
border-style:solid;
border-width:2px;
width:196px;
height:196px;
float:left;
}
</style>
</head>

<body>
<div id="trigger1">
Trigger One
</div>
<div id="trigger2">
Trigger Two
</div>
<div id="trigger3">
Trigger Three
</div>
<div id="viewport">
<div id="container">
<div id="box1" class="box">
Box One
</div>
<div id="box2" class="box">
Box Two
</div>
<div id="box3" class="box">
Box Three
</div>
</div>
</div>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:29:50+00:00Added an answer on June 7, 2026 at 12:29 pm

    I’d suggest that you restructure your trigger menu and rewrite your JQuery code like this:

    HTML

    <ul id="triggerMenu">
        <li id="trigger-0">One</li>
        <li id="trigger-1">Two</li>
        <li id="trigger-2">Three</li>
    </ul>
    
    <div id="viewport">
        <div id="container">
            <div id="box1" class="box">Box One</div>
            <div id="box2" class="box">Box Two</div>
            <div id="box3" class="box">Box Three</div>
        </div>
    </div>​
    

    JQuery

    $("li", "#triggerMenu").on("click", function()
    {
        var triggerNumber = $(this).attr("id").replace(/(.*)-/,"");
        var newPosition = triggerNumber * 200;
    
        // Make sure the box slides in the right direction
        if (newPosition > 0) newPosition = "-" + newPosition;
    
        // Slide box
        $(".box").animate({left: newPosition});
    });
    

    This way you don’t have to add new JQuery code for each trigger/box combo.

    Live demo: http://jsfiddle.net/fAWpZ/5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.