Divs gracefully move from left to right in a smooth transition

I need help with my HTML 5 application. I am trying to create a sliding menu that is responsive and has a left/right transition, with the first panel always visible for 100px on the right.

However, I am encountering an issue where the first <div> passes over the original <div>.

HTML:

<div id="myContainer">
    <div class="animate1 animate1-nomove">
        <section class="myPanel panel-padding">new new new new new</section>
    </div>
    <div class="animate2 animate2-nomove">
        <section class="myPanel panel-padding" id="scrolling">original</section>
    </div>
</div>

CSS:

div#myContainer {
    position: absolute;
    top: 60px; right: 0; bottom: 60px; left: 0;
    /* necessary for sliding menu */
    overflow: hidden;
    border: 1px solid;
}

div.animate1 {
    height: 100%;
    width: 100%;
    background-color: #c00;
    -webkit-transition: 2s ease-in-out;
    -moz-transition: 2s ease-in-out;
    -o-transition: 2s ease-in-out;
    -ms-transition: 2s ease-in-out;
    transition: 2s ease-in-out;
    position: absolute;
}

div.animate2 {
    height: 100%;
    width: 100%;
    -webkit-transition: 2s ease-in-out;
    -moz-transition: 2s ease-in-out;
    -o-transition: 2s ease-in-out;
    -ms-transition: 2s ease-in-out;
    transition: 2s ease-in-out;
    position: absolute;
}


/* no move */
.animate1-nomove {left: -100%;}
.animate2-nomove {left: 0px;}

/* move */
.animate1-move {left: 0px; margin-right: 100px;}
.animate2-move {left: 100%; margin-left: -100px;}

Check out my JSFiddle for a demo: http://jsfiddle.net/nKtC6/714/

Answer №1

Are you attempting to achieve this?

http://jsfiddle.net/prollygeek/nKtC6/716/

div.animate1 {
  height: 100%;
  width: 100px;
  background-color: #c00;
  -webkit-transition: 2s ease-in-out;
  -moz-transition: 2s ease-in-out;
  -o-transition: 2s ease-in-out;
  -ms-transition: 2s ease-in-out;
  transition: 2s ease-in-out;
  position: absolute;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Create a dynamic Bootstrap progress bar that smoothly transitions from 0 to 100%

I am currently utilizing Twitter Bootstrap to construct my webpage. Here is the snippet of HTML code I have: <div class="btn-group"> <button type="button" class="btn btn-success">Connect</button> <button type="button" class=" ...

What's the best way to use CSS to center an HTML element on a page?

My goal is to perfectly center an HTML element on a page, ensuring that the center of the element aligns with the center of the page. The current code I am using is as follows: #associate { position:absolute; color:white; background-color:red; ...

Modifying the color of text within an element using CSS and the ::after pseudo

Is there a way to change the text color when a user hovers over it without interfering with the background effect? I currently have a hover effect set to show a background section when hovering over the text, but when I try to change the text color separat ...

What is the method of transferring the selected tag value to PHP using Ajax post?

I am currently facing an issue with my HTML select code. Here is the snippet: <div> <select id="pickType" class="form-control select2 " name="pickType"> <option value="" selected="selected">Select Type</option> ...

Separate jQuery code from the PHP-generated HTML output

Experimenting with PHP and probably not doing it correctly, but this is just a proof of concept to get approval for the right approach. I am using a php script for login and posting variables from forms. The issue: I am echoing out an HTML code that inclu ...

How can I display the default value in a jQuery radio button when it changes?

I recently started developing and I encountered an issue with a change event function for two radio buttons that have the same name and id but different values. When I trigger the change event, the default value related content doesn't appear until a ...

Require assistance in building a responsive two-column div with full-height, vertical-center content in one div, and an image carousel in the second div

I am trying to develop a responsive layout with two columns, where the right column will have vertically centered content and the left column will contain a full-height and width image carousel. For mobile and tablet screens, the design should look like t ...

assigning a numerical value to a variable

Is there a way to create a function for a text box that only allows users to input numbers? I want an alert message to pop up if someone enters anything other than a number. The alert should say "must add a number" or something similar. And the catch is, w ...

What is the best way to handle form submission when a function returns false on success?

My form has a click event that triggers when the create button is clicked: (Please note: I'm working with Wordpress, so 'jQuery' is equivalent to '$') jQuery('.btn-create').click(function(e){ var charname = jQuery( ...

What are some ways to create a flashing effect for text in HTML and JavaScript?

Although flashing text is typically prohibited in many places, my client has requested it for a project. I need to create one line of text that flashes using HTML and JavaScript. The text should appear and disappear within seconds, repeating this cycle. I ...

What is the best way to conceal the style attribute?

Is there a way to hide the style attribute in HTML while still keeping it functional? For example: <html style="--color:#1E90FF;"> I tried using removeAttr to remove the attribute, but it stopped working completely. I can't achieve this throug ...

Arrange css3 menu circles to be displayed next to each other

I have managed to figure out most aspects of these circles except for how to arrange them side by side. Currently, they are stacked on top of each other. I have successfully determined the colors, fonts, text positions, and other details with some assistan ...

How come the Hover effect is activated even without hovering the mouse over the text?

I have designed a dropdown menu, but I am facing an issue with the portfolio section. When I hover over the portfolio, the dropdown menu appears correctly. However, when I hover over the text of the first dropdown menu, all sub-dropdown menus from other dr ...

Retrieve Latitude and Longitude by clicking using JavaScript

When I click on the map, I want to retrieve the latitude and longitude coordinates and display them in an alert. Here is the code I have: <!DOCTYPE html> <html> <body> <div id="googleMap" style="width:100%;height:400px;"></div&g ...

Utilizing jQuery to generate dynamic nested divs within the ul li tags

I am looking to dynamically generate nested divs within a ul li. The goal is to create the following structure programmatically: <ul> <li> <div class="videoThumbnail"> <img src="./img6.jpg" /> &l ...

Tips for achieving seamless expansion and eliminating grid row gaps by utilizing hidden elements in CSS

I'm currently developing a web design that includes a section with both visible and hidden content. I've added a button to smoothly reveal the hidden content using a transition effect. However, I'm encountering a couple of challenges: Even ...

Utilizing jquery-confirm for Efficiently Redirecting Links in a Web Browser

I recently started using the jquery-confirm v3.0.3 plugin (available at ) to confirm various actions on my website. However, after implementing the code below, I noticed that the action specified in the link's href attribute is not being executed whe ...

Choosing a specific column in an HTML table using jQuery based on the text within it

I have a table with a similar structure as shown below: <table> <c:forEach ...> <tr> <td>test</td> // this is the initial value <td>random value</td> <td>random value</td&g ...

What is the best way to integrate bootstrap modal forms using django-crispy-forms without causing a page refresh?

Recently, I've been working on setting up a form within a bootstrap modal using django-crispy forms and class-based views. While looking into incorporating Ajax functionality, I found several examples that weren't entirely clear to me. I tested ...

moving forward and backward using jquery

I have a webpage featuring multiple boostrap cards, and I'm looking to display these cards one by one without the need to reload the page. <div class="card mt-2" id="card-b"> ... <button type="button" id=&q ...