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

  • Home
  • SEARCH
  • 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 6905415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:10:50+00:00 2026-05-27T08:10:50+00:00

I have a little function that toggles my content from the left to the

  • 0

I have a little function that toggles my content from the left to the right with a sliding effect. Unfortunately the two div objects (with inline-block) due to their size don’t align next to each other when sliding, but one of them is obviously always beneath the other one.

See the jsfiddle code here

I tried the following:

  • setting a float:left didn’t help at all
  • positioning the divs absolute, which helped but also created some unexpected behaviour when sliding from the right to the left (try it yourself)
  • delaying/queueing the animations, works but not really user-friendly with the delay

I also want to mention that floats and different positioning aren’t very helpful when you want your objects all centered, so I’d prefer another solution anyway.

Maybe you guys got an idea, how I could make this smooth, so that the divobjects stay in one line ?!

  • 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-05-27T08:10:51+00:00Added an answer on May 27, 2026 at 8:10 am

    Did a lot of changes, sorry about that, but try this:

    http://jsfiddle.net/jcZ6J/9/

    Also note, that you should not place a div inside an a tag.

    HTML

    <div class="content">
      <a href="index.php?show=camp" class="container" data-title="camp"><h2>CAMPS<br />149 &euro;</h2></a>
      <a href="index.php?show=course" class="container" data-title="course"><h2>COURSES<br />49 &euro;</h2></a>
    
      <div class="slider-viewport">
        <div class="slider-carriage">
            <div id="camp" class="show" title="left"><span>CAMP-INFO</span></div>
            <div id="course" class="show" title="right"><span>COURSES</span></div>
        </div>  
      </div>
    </div>
    

    JS

    $(function() {
        $('.container').click(function(evt) {
            evt.preventDefault();
            $('.slider-carriage').stop(false, false).animate({
                left: (-100 * $('#' + $(this).data('title')).position().left / $('.slider-viewport').width()) + '%'
            }, 1000);
        });
    });
    

    little update here so that resizing the window is not a problem


    CSS

    @charset "utf-8";
    
    body {
        color: #FFF;
        background-color:#09F;
        font-family: "Arial";
        font-size: 14px;
        margin: 0px;
    }
    
    /* CONTENT */
    .content {
        width:100%;
        text-align:center;
    }
    
    .container {
        text-align: center;
        display: inline-block;
        border: 2px solid #FFF;
        background:rgba(0,0,0,0.5);
        width:180px;
        margin-left:10px;
        margin-right:10px;
        padding-top:20px;
        margin-top:95px;
    }
    
    .container:hover {
        border:2px solid #CCC;
        color:#0F0;
    }
    
    .slider-viewport {
        position: relative;
        overflow: hidden;
        width: 90%;
        margin: 50px auto;
        height: 20px;
    }
    
    .slider-carriage {
        position: absolute;
        width: 200%;
    }
    
    .show {
        float: left;
        text-align: center;
        background: #F90;
        width: 50%;
    }
    
    .show > span {
        display: block;
        border: 2px solid #FFF;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just programming a little function that toggles a content by fading it in
I need to write a little ruby function that does word wrapping. I have
I have a little dropdown menu similar <select> , which contolled from external js-function.
I have a little function that shows latest activity, it grab timestamp in unix
So I have this neat little javascript function that I'm using to print text
I have a little script that shows a div when an arrow is clicked.
I have a little problem. I have a program that will draw wave function
I have a little problem with preg_replace . I need a function that removes
I have a little AJAX function that asks the server whether a particular checkbox
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),

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.