Could the conflicting interaction between CSS transformation and animation be resolved by adjusting the order of the HTML elements

Hey there! I'm facing an interesting challenge with my menu design. The menu has rounded ends and diagonal spaces created using CSS transform skewx. Additionally, I have an animated element on the page.

The issue arises when the animated element is placed before the menu in the DOM - it causes the menu to deform until the animation completes. However, placing the animated element after the menu in the DOM solves this problem.

I really want to keep the animated element at the top of the DOM. Any suggestions on how I can tackle this issue using CSS?

Check out JSFiddle demo

Here's the markup:

<div class="testanimation"></div>

<div class="testmenu">
    <ul>
        <li class="one"><span><p>ONE</p></span></li>
        <li class="two"><span><p>TWO</p></span></li>
        <li class="three"><span><p>THREE</p></span></li>
        <li class="four"><span><p>FOUR</p></span></li>
    </ul>
</div>

And here's the relevant CSS code:

@-webkit-keyframes cart-modified{
    0% {
        -webkit-transform: scale(1);
    }
    35% {
        -webkit-transform: scale(1.5);
    }
    100% {
        -webkit-transform: scale(1);
    }
}
.testanimation{
    -webkit-animation: cart-modified 0.5s ease 2 0.25s;
    min-width: 1.25em;
    padding: 0.25em;
    position: absolute;
    top: 3px;
    background-color: #fa001f;
    background-color: rgba(250, 0, 31, 0.9);

}

.testmenu ul{
    display: flex;
    display: -webkit-box;
    border-radius: 50px;
    overflow: hidden;
    width: 95%;
}
.testmenu ul li{
    transform: skewX(-45deg);
    -webkit-transform: skewX(-45deg);
    margin: 0 5px 0 5px;
    background-color: #e8e8e8;
    width: 25%;
    text-align: center;
    list-style: none;
}
.testmenu span{
    transform: skewX(45deg);
    -webkit-transform: skewX(45deg);
    display: block;
    color: white;
}
.one{
    padding-left: 40px !important;
    margin-left: -60px !important;
}
.four{
    padding-right: 40px !important;
    margin-right: -30px !important;
}

Thanks for sharing your expertise!

Answer №1

This is a strange issue because it seems like CSS animations are meant to be asynchronous. To work around it, I've found that adding a skewX(0) property to the ul also helps.

.testmenu ul{
    -webkit-transform: skewX(0);

Take a look at this example: http://jsfiddle.net/9Lgq205d/

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

Can you explain the distinction between ' &:hover' and ' & :hover' pseudoclass selectors?

While styling a Material-UI Button, I encountered an unexpected behavior when adding hover effects. When using & :hover, only the inner span of the button was affected. However, when using &:hover, the desired style was achieved. What is the diff ...

Use either Jquery or CSS3 to hide a div if one of its inner divs is empty

I have multiple data sets to display in divs with the same class name. Each div contains two inner divs. <div class="div1"> <div class="div2">Abc</div> <div class="div3"><?php echo $row['SOME VALUE']; ?>< ...

Calculating the calc()-expression in Fluid Typography Linear Transition

After exploring the technique demonstrated by Mike Riethmuller, which involves utilizing calc() to create a fluid font-size transition between a minimum and maximum value, I found the outcome obtained from calc() in the browser somewhat perplexing (and not ...

Issue with IE7 causing rollover navigation blocks to disappear when hovering over content

While conducting browser testing on the website The website's top navigation menu includes rollover effects for building services, exterior services, and commercial categories. The CSS-triggered navigation works seamlessly in all browsers except for ...

What's the Best Way to Add a Border to My Two-Column Form?

I'm currently working on a reservation form for my website with a 2-column layout. In one column, I have tables, and I've been trying to add a divider between the columns but haven't found a solution yet. Despite researching ways to add a d ...

Is there a way to set the starting position of the overflow scroll to the middle?

Is there a way to have the overflow-x scrollbar scroll position start in the middle rather than on the left side? Currently, it always begins at the left side. Here is what it looks like now: https://i.stack.imgur.com/NN5Ty.png If anyone knows of a soluti ...

The JQuery loading symbol does not prevent keyboard interactions

I successfully implemented a Jquery busy indicator in my application using the following link: However, I noticed that even though it prevents users from clicking on input elements while loading, I can still navigate to these elements by pressing the tab ...

Arrange various Div elements of varying sizes in a predetermined sequence

I need to ensure that a large div maintains the same height as 20 other divs within the same container, when the screen size is between 1024px and 1920px in width. The challenge lies in arranging all these items in a floated layout grid that looks clean a ...

Transferring live data between AJAX-triggered pop-up windows

Utilizing modals frequently in my application is a common practice. There are instances where I need to transfer data from one modal box to another. For instance: Suppose there is a table listing different car manufacturers (Audi, BMW, Honda, etc). Each r ...

Turning off font ligatures in CSS (letter connections deactivation)

Typically, modern web browsers will automatically merge certain letter combinations, such as 'f' and 'i', into a single character known as a ligature. While this can enhance readability, it may not always align with a designer's pr ...

Using PHP to nest a table within HTML and populate it with numbers ranging from 1 to 100

I am struggling with a practice question that involves creating a table using PHP nested in HTML. I need some help fixing it and understanding where I went wrong. The task is simple: generate numbers from 1 to 100 in a table, with each row containing 10 n ...

Is it feasible to send a GET form to two separate views using two buttons?

On one view, I have a form that functions perfectly. http://myurl.com/myapp/filter_objects/?risk__worktask=1&craft=3 In another view, I need to export the filtered list to a PDF. Currently, I store the results in session and access the list from ther ...

What is the best way to incorporate web components into a React Js project?

I am currently unfamiliar with web components. My main goal is to integrate Google Material Components into my React.js project. Google Material Web Component can be found here: https://github.com/material-components/material-components-web Is there a ...

Why isn't margin working with position: fixed?

I need help finding a solution for incorporating margin in a box within my App class. The issue is that the position fixed property doesn't seem to work as intended. <div className="App"> <div className="box"> ...

Leveraging JavaScript along with the jQuery library and API to showcase information related to

Hey there! I have been working on this API that shows upcoming concerts, but I'm struggling to display the images associated with each concert. I've tried using for loops to iterate through the objects, and it seems like every sixth element has ...

What are the reasons for the decrease in canvas text quality when using requestAnimationFrame?

I have created a unique canvas effect where text changes color using requestAnimationFrame: var text = 'Sample text'; ctx.fillText(text,canvas_width/2,100); requestAnimationFrame(animate); function animate(time){ ctx.fillText(text,-offset,100 ...

Apply CSS styles when the text exceeds the size of the textbox

Is there a way to create a textbox that scrolls on hover only if the text is longer than the textbox itself? Check out my attempt here: https://jsfiddle.net/SynapticError/wqh4ts3n/35/ The text should scroll on hover if it's longer than the textbox. ...

Send back alternate HTML content if the request is not made via AJAX

Last time I asked this question, I received several negative responses. This time, I will try to be more clear. Here is the structure of a website: Mainpage (Containing all resources and scripts) All Other pages (HTML only consists of elements of that ...

Notification continuously appears when clicking outside of Chrome

I have implemented the use of onblur on a text box to display an alert. However, I encountered an issue where if I click outside my Chrome browser after entering text in the text box and then click on the Chrome browser button in the task bar, the alert ap ...

incorporating video content onto a webpage

Let me provide more details for better understanding. Currently, the website is not operational yet. Once it's live, I'll be hosting it on a platform like YouTube. The issue I encountered was when trying to embed a video using the code below: & ...