What might be causing my CSS animations to fail on Safari for iPhone when they work correctly on all other devices?

I am currently working on developing a website using HTML and CSS (without JavaScript), and I have implemented a keyframes animation in the navigation menu that triggers on :hover and :active states to display a sub-menu.

The Issue: The animation functions correctly on all web browsers on laptops (including Safari) and most of the browsers on Android mobile devices. However, it does not work on iPhones with Safari, but it works fine on other browsers like Chrome.

This is my first real website project, and I'm unfamiliar with this particular problem, so I'm unsure of what's causing it.

Actions Taken So Far: I attempted adding -webkit- prefixes wherever applicable, but it did not solve the issue. I also tried breaking down the animation parameters by using properties such as animation-name:, animation-duration: instead of combining them under a single 'animation:' property – but that didn't help either.

These are all the solutions I could think of at the moment.

Safari Development Tools: One thing worth mentioning (though I'm uncertain if it's significant), since I own a Mac, I utilized Safari's development tools to pinpoint the issue. Surprisingly, the problem doesn't manifest there. As I lack an iPhone device for testing purposes, I'm essentially operating blindly here. If you know about any simulators or tools that can replicate an iPhone environment, kindly let me know.

Appreciate your assistance!

.menu-primaire {
    transition: all 500ms;
    &:hover, &:active {
        & .head_liste__secondaire {
            display: inline-block;
            position: relative;
            top:   25px;
            right: 34%;
            padding: 0px;
            @media screen and (max-width: 768px) {
                right: 0;
            }
            @media screen and (max-width: 425px) {
                position: absolute;
                top: 70px;
            }
        }
    }
}

.menu-secondaire {
    -webkit-animation-name: menu;
    -moz-animation-name:    menu;
    animation-name:         menu;

    -webkit-animation-duration: 500ms;
    -moz-animation-duration:    500ms;
    animation-duration:         500ms;

    -webkit-animation-fill-mode: both;
    -moz-animation-fill-mode:    both;
    animation-fill-mode:         both;
    
    @for $i from 1 through 4 {
        &--#{$i} {
            -webkit-animation-delay: 100ms * $i;
            -moz-animation-delay:    100ms * $i;
            animation-delay:         100ms * $i;
        }
    }
}

@-webkit-keyframes menu {
    0% {
        -webkit-transform: translate3d(0,10px,0);
        opacity: 0;
    }
    100% {
        -webkit-transform: translate3d(0,0,0);
        opacity: 1;
    }
}

@-moz-keyframes menu {
    0% {
        -moz-transform: translate3d(0,10px,0);
        opacity: 0;
    }
    100% {
        -moz-transform: translate3d(0,0,0);
        opacity: 1;
    }
}

@keyframes menu {
    0% {
        transform: translate3d(0,10px,0);
        opacity: 0;
    }
    100% {
        transform: translate3d(0,0,0);
        opacity: 1;
    }
}
<nav>
  <ul class="head_liste">
    <li class="head_liste__primaire menu-primaire"><a href="#">Button 1</a></li>
    <li class="head_liste__primaire menu-primaire">Button 2
      <ul class="head_liste__secondaire">
        <li class="menu-secondaire menu-secondaire--1"><a href="#">Button 1a</a></li>
        <li class="menu-secondaire menu-secondaire--2"><a href="#">Button 1b</a></li>
        <li class="menu-secondaire menu-secondaire--3"><a href="#">Button 1c</a></li>
        <li class="menu-secondaire menu-secondaire--4"><a href="#">Button 1d</a></li>
      </ul>
    <li class="head_liste__primaire menu-primaire"><a href="#">Button 3</a></li>
  </ul>
</nav>

Answer №1

In case someone else encounters a similar problem, I wanted to share the solution that worked for me (which involves using JavaScript).

I created a button element for "button 2" and implemented an onclick function that adds a new class when clicked. Then, I proceeded to work with this added class to achieve the desired functionality.

Although it may not be the most ideal solution and does require some knowledge of JavaScript, it successfully resolved the issue for me!

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

Flutter button with a curved edge

I've been attempting to create a curved button in my Flutter project, but it seems like the borderRadius property is not functioning properly for me. Below is the code snippet that I have been working on: //Login Button final loginButton = Pa ...

Replace all occurrences of the text/css style tag with an empty string using

I'm struggling with my PHP code and I need some assistance in removing the style type="text/css" tag. My goal is to replace this tag with an empty string. Here's the code snippet I've tried: if (strpos($inbox_message, '<style type= ...

"Implementing Mixpanel's iOS SDK with Automatic Reference Counting

When attempting to incorporate the Mixpanel SDK into my iOS app using ARC, I encountered compile errors. What is the best approach to integrating Mixpanel into an ARC-powered project? Typically, I handle memory management manually in my personal projects. ...

Using AngularJS to incorporate personalized font icons

Looking to create a custom font icon library similar to "Font Awesome" for my AngularJS project, as using fonts instead of images is more versatile across devices. Is there a way to achieve this? I have generated a font in .ttf and .svg formats with my ...

Tips for creating the appearance of a resizable element

My goal was to replicate the resizing and moving functionality of elements in Adobe Illustrator using CSS alone. Unfortunately, I couldn't find any useful resources on how to achieve this. ...

Set the style to be displayed as a block element

I am working on a Rails application that contains some <li> elements with the CSS property display: none;. I want these elements to only appear on the page when they are being dragged. However, there are some elements that do not have the display: no ...

Adjust the margin of FormHelperText within a FormControl specifically for a Select component in Material-UI

I'm currently facing a challenge where I need to add marginLeft of 8px to FormHelperText. However, I have not been successful in doing so within the MuiInput formControl rule or in MuiSelect. Here is the React code snippet: <FormControl error clas ...

The Javascript Navbar is malfunctioning on Firefox

Currently, I am working on a horizontal menu that includes submenus. My goal is to use Javascript to display the submenu when a user hovers over the parent menu. I created a JSFiddle example, which seems to be experiencing issues in FireFox! However, it w ...

Place the delete and edit buttons on the right side of the card

I am trying to align the edit and delete buttons with the image and premise name on the same line. Both buttons should be placed on the right side and have the same size as the card. Currently, the layout looks like this: https://i.sstatic.net/sNikU.png ...

How can I arrange individual events in agendaWeek view on FullCalendar.io and then merge them all into one line?

I am using Fullcalendar.io version 2 When I switch to the agendaWeek mode, all my events are displayed on one line in each day square. As a result, the more events I have, the thinner the event blocks become. Is there a way for me to display only one eve ...

Error encountered when attempting to perform an HTTP Post to a Restful web service using TCP

When I try to upload videos from my mobile client to a restful web service using HTTP post binary stream Upload, I am encountering an issue. Small videos of 3-4 seconds in length can be successfully uploaded, but larger videos result in an error from the s ...

Tips on adding style to your jQuery autocomplete dropdown

I am currently utilizing jQuery autocomplete functionality. I have configured it to communicate with a service and retrieve records: <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1 ...

Designing a flexible and consistent grid system using only CSS to showcase any number of images, ensuring each tile seamlessly adjusts to the dimensions of the largest element

[edit : preamble] Regardless of the nature of your response, please support your arguments with technical references from credible sources. Appreciate your help in advance. [Question] I am seeking to design a CSS grid layout that is responsive for image ...

New label design for see-through surface at 50% transparency with alpha value of 0

I am experiencing an issue with making my CollectionView cell transparent while keeping the labels within it opaque. I have set the background of the CollectionView cell to be partially transparent (alpha value 0.5) and placed a content view beneath with ...

Decoding JSON in Swift 3

Having some trouble working with JSON in my Firebase project. Initially, everything was smooth sailing with the old code. Then, I made the decision to "nest" the company information within the "campaign". Here's a snippet of the JSON: "title" : "Som ...

The functionality of onClick or onChange seems to be malfunctioning in the preline user interface select component

I recently integrated the preline UI library into my React project to enhance the design of my website. However, I encountered an issue where using the "select" element with the data-hs-select attribute as suggested by preline UI seemed to cause problems w ...

Can anyone provide instructions on how to create a theme change animation using Vuetify?

Follow these steps to understand what I'm describing: Go to the Vuetify website Click on the settings icon Choose between the dark or light theme option. When you switch between themes, there is an animation that occurs. A circle starts expanding fr ...

Having difficulty adjusting the margin-top for the menu div

Why am I unable to apply margin to my a links within the div identified by id="menu". I can successfully implement margin-left, but when attempting to use margin-top or margin-bottom, it does not work as expected. I wish to adjust the position o ...

IOS Display Dimension Guidelines

My iphone app is almost finished, but unfortunately it does not support 3.5 inch screens. Are all apps required to be compatible with versions 4 and below of the iphone/ipod? Do I have to make changes to my app? In other words, I'm wondering if my a ...

Adjust the placement of a dropdown menu placed within a table

I have successfully implemented a sticky table header, but I am encountering an issue with the select element integrated into my table: View before scrolling the table View after scrolling the table As you can see, the select element overlaps with the t ...