The span exits the external div only once the animation has concluded

I utilized jQuery to create an animation effect:

http://jsfiddle.net/rxCDU/

UPDATE: Please note that this effect is optimized for Chrome browsers!

The animation works correctly, however, the green SPAN element moves out of the red DIV only after the animation ends. I want the green SPAN to be positioned over the red DIV from the start of the animation. I attempted adjusting the z-index and position styles in CSS but didn't achieve the desired outcome.

HTML:

<div class="ext_div">
   <div class="int_div"><span>A</span></div>
</div>

CSS:

.ext_div {
    -webkit-transform: rotate(-50deg);
}

div.ext_div div {
    background-color: red;
    position: relative;
    margin-top: -400px;
    padding-left: 80px;
    width: 200px;
    height: 250px;
    font-size: 350px;
}

div.ext_div div span {
    background-color: green;
    width: 100px;
    float: left;

    -webkit-transform: skewY(50deg);
    -moz-transform: skewY(50deg);
    -o-transform: skewY(50deg);
    -ms-transform: skewY(50deg);
    transform: skewY(50deg);
}  

jQuery Code:

$(document).ready(function() {

     $(".int_div").queue(function () {
        $(this).animate({width: "150", height: "125", right: "+=200", "font-size": "150px" }, 1200)
               .queue(function () {
                    $(this).addClass("myclass");}).dequeue();
     });    

 return false;

});

Any suggestions on how I can resolve this issue? Thank you in advance!

Answer №1

When using jQuery to animate, it may be necessary to add overflow hidden. I discovered 2 solutions for this issue.

The first solution involves adding overflow visible to the div with !important (though not recommended).

div.ext_div div {
    overflow : visible!important;
    background-color: red;
    position: relative;
    margin-top: -400px;
    padding-left: 80px;
    width: 200px;
    height: 250px;
    font-size: 350px;
}

Link to jsfiddle example: http://jsfiddle.net/rxCDU/2

The second approach is to utilize the step function and override the overflow property:

$(this).animate({width: "150", height: "125", right: "+=200", "font-size": "150px" }, {duration : 1200, step : function(){
         $(this).css('overflow', 'visible')
}})

Link to updated jsfiddle demo: http://jsfiddle.net/rxCDU/4/

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

if statement not recognizing data returned from PHP function

I'm currently working with a function that is being used for an AJAX query: var formData = $(this).serialize(); //store form names and values in an array called 'formData' $.get('filtertest.php',formData,processData); //jQ ...

Explore the wonders of Google Maps with the convenience of bpopup through ajax

I am currently using the bpopup plugin for ajax popups on my website. I have successfully implemented a popup with a Google map, but I am facing some issues when loading the map asynchronously. JavaScript $(document).on('click', '.aboutBranc ...

Utilizing CSS grid layouts to ensure images expand to fit the dimensions of the designated column and

I am currently working with a CSS grid layout that is displaying as follows: .image__gallery-grid { max-height: none; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 2.5rem; dis ...

How to find and pair up custom data attributes that are unfamiliar?

Is there a method to select elements with unspecified custom data attributes? When I say unspecified, I am referring to an element that could appear like this: <div data-unknown="foo"></div> or <td data-someOtherCustomDataAttribute="bar"& ...

Tracking the advancement of synchronous XMLHttpRequest requests

Within the client-side environment, there exists a File-Dropzone utilizing the HTML5 File-API which allows users to drop multiple files for uploading to the server. Each file triggers the creation of a new XMLHttpRequest Object that asynchronously transfer ...

When switching from JavaScript to jQuery, the button values become invisible

Currently, I have a functional app that can dynamically change the values of buttons based on user input. The current implementation is in vanilla JavaScript within the script.js file. However, I am looking to enhance the functionality and user experience ...

I am unable to select the first item when using select2.js and setting a placeholder

I am experiencing an issue with my <select> list that is styled using select2.js. Everything seems to be functioning properly, except for when a placeholder is used. Users are unable to select the first item in the list initially. If they choose any ...

Is there a way to identify when a Tween.js animation has completed?

Is there a completed or finished event available when using this code for animating the camera in a scene with tween.js? tween : function (target){ var position = camera.position; var tween = new TWEEN.Tween(p ...

Set a dynamic pixel height for a div to enhance the smoothness of slideToggle animation

I'm struggling with creating a slideToggle menu bar for my responsive layout that uses percent width instead of pixels. The issue I'm facing is that the slideToggle function appears to be jumpy due to this setup. Are there any better alternatives ...

Is it possible to shift the div inline-block using the CSS :after selector?

I'm looking to adjust the placement of the disk icon so that it aligns more with the baseline of the text without increasing the vertical space between lines. Below is the CSS code I've worked on so far: .openPage:after { content: ' &a ...

Is there a way to use JQuery/AJAX to extract the selected values from all drop-down menus within a designated container?

With the help of JavaScript, I am dynamically creating dropdown lists under dvContainer. My goal is to retrieve the selected values of all select elements within that container. Below is the HTML code generated through JavaScript: <div id="dvContai ...

What could be the reason for the body background color refusing to change

I'm currently working on a JavaScript calculator project and I'm using this code snippet from codepen. The issue I'm facing is that despite setting the body background color to black, it still appears white. Could there be a spacing problem ...

GWT Designer style issue plaguing development efforts

Currently, I am working on designing a login view using GWT Designer while incorporating styles from Twitter Bootstrap. The structure I have set up is as follows: However, the displayed result does not meet my expectations: Despite setting all CSS paddi ...

When I access the website through the LinkedIn app, my CSS styles are getting jumbled up

Is there a way to resolve the problem I'm facing with CSS when accessing the site through the LinkedIn app on iPhone? The issues don't occur on Android. If anyone has a solution, please share. Thank you :) Click Here ...

Tips for aligning three <p> elements side by side using flexbox

I need assistance with aligning three boxes next to each other, each containing an image, header, and text. The issue arises when resizing the browser, causing the content in box 2 and 3 to be positioned higher than box 1. Below is the code I have been us ...

Box-free calendar dash component

Encountering an issue within my application dashboard, here's a direct screenshot: https://i.stack.imgur.com/sEMrM.png The problem is that the Calendar days are extending beyond the borders of the calendar box. To implement this, I simply utilized ...

Upgrade jQuery visibility and opacity animations to pure JavaScript for a more lightweight solution

Currently I am in the process of removing jQuery from an older website. However, I have encountered a problem with an animation that is currently being used. I have managed to replicate the opacity fade effect, but I am struggling to smoothly transition t ...

How to activate select only when specific options are chosen using jQuery

I am working on a form that has 1 select element disabled, with 4 options. I am looking to implement a jQuery function that will perform the following actions: If OPTION #1 is clicked, it should check if any other options are selected and reset them (eras ...

modify CSS style once the modal has been hidden

Is there a way to change the default background color of my table row back to normal after closing the modal window that appears when I click on it? <tr class='revisions'> <td>{{ $revision->date_of_revision->format(' ...

Determine whether the browser tab is currently active or if the user has switched to a different

Is there a way to detect when a user switches to another browser tab? This is what I currently have implemented: $(window).on("blur focus", function (e) { var prevType = $(this).data("prevType"); if (prevType != e.type) { // handle double fir ...