CSS animations are only functional when the Developer Tools are activated

I recently implemented a transition to uppercase in CSS, but it seems to only work when I open dev tools in Mozilla and not at all in Chrome. This is my first attempt at using animations in CSS, so any feedback on my code is appreciated.

I'm curious if the animation could be influenced by changes in window height when I open Dev Tools, or if there's some hidden magic at play that alters the page's behavior?

CSS:

.headerHeading{
    color: blue;
    background-color: inherit;
}
nav {
    position: sticky;
    position: -webkit-sticky;
    top: 0;
    background: #27009c;
    border: 1px #180062;
}


.nav-selections > a{

    text-transform: uppercase;
    letter-spacing: 5px;
    /*font: 18px "lato", sans-serif;*/
    /*display: inline-block;*/
    text-decoration: none;
    color: white;
    padding: 18px;
    float: right;
    /*margin-left: 50px;*/
    transition: 1.5s;
}

.nav-selections>.changeColorAnim:hover {
    transition: 1.2s;
    color: rgba(77,77,77,0.97);
}

ul {
    margin: 0 !important;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    flex-flow: row nowrap;
    /*background-color: #B79b58;*/
    /*overflow: auto;*/
}

li {
    flex: 1;
    list-style: none;
}

HTML:

<link rel="stylesheet" href="styles/header.css">

<nav>
<ul>
    <li class="nav-selections"><a href="index.php" class="changeColorAnim">Home</a></li>
    <li class="nav-selections"><a href="pages/schedule.html" class="changeColorAnim">Program</a></li>
    <li class="nav-selections"><a href="pages/contact.html" class="changeColorAnim">Contact Us</a></li>
    <li class="nav-selections"> <a><?php
        if ($username != ""){
            echo $username;
        }else{
            echo "nepřihlášený";
        }
        ?>
            </a>
    </li>
    <li class="nav-selections"><a href="pages/login.php" class="changeColorAnim">Přihlásit/Registrace</a></li>
</ul>

Actual and expected behavior

https://i.sstatic.net/XH7ip.gif

https://i.sstatic.net/dN5qp.gif

Answer №1

It seems like the animation is missing from your code.

To add the animation, include the following code snippet with

animation: add-padding 0.5s ease 1 forwards;
within the .nav-selections > a style section.

@keyframes add-padding{
  0%{
      padding:0;
  }
  100%{
    padding:18px;
  }
}

Refer to the Snippet below:

.headerHeading{
    color: blue;
    background-color: inherit;
}
nav {
    position: sticky;
    position: -webkit-sticky;
    top: 0;
    background: #27009c;
    border: 1px #180062;
}


.nav-selections > a{

    text-transform: uppercase;
    letter-spacing: 5px;
    /*font: 18px "lato", sans-serif;*/
    /*display: inline-block;*/
    text-decoration: none;
    color: white;
    float: right;
    /*margin-left: 50px;*/
     animation: add-padding 0.5s ease 1 forwards;
    transition: 1.5s;
}
@keyframes add-padding{
  0%{
      padding:0;
  }
  100%{
    padding:18px;
  }
}
.nav-selections>.changeColorAnim:hover {
    transition: 1.2s;
    color: rgba(77,77,77,0.97);
}

ul {
    margin: 0 !important;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    flex-flow: row nowrap;
    /*background-color: #B79b58;*/
    /*overflow: auto;*/
}

li {
    flex: 1;
    list-style: none;
}
<link rel="stylesheet" href="styles/header.css">

<nav>
<ul>
    <li class="nav-selections"><a href="index.php" class="changeColorAnim">Home</a></li>
    <li class="nav-selections"><a href="pages/schedule.html" class="changeColorAnim">Program</a></li>
    <li class="nav-selections"><a href="pages/contact.html" class="changeColorAnim">Contact Us</a></li>
    <li class="nav-selections"> <a><?php
        if ($username != ""){
            echo $username;
        }else{
            echo "nepřihlášený";
        }
        ?>
            </a>
    </li>
    <li class="nav-selections"><a href="pages/login.php" class="changeColorAnim">Přihlásit/Registrace</a></li>
</ul>

You can check out the animation in action by visiting this link

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

Get rid of the box-shadow on the Vuetify element

I currently have a special-table component that includes a box shadow when the row is expanded https://i.stack.imgur.com/8zgjp.png I am aiming for the removal of the box-shadow effect. After inspecting the console-style tab, I identified https://i.stac ...

What is the method for altering the text color within a disabled input field?

Currently facing difficulty in changing the color of the text within the input field when it's disabled. I'm utilizing Material UI for this purpose. import React from "react"; import { makeStyles } from "@material-ui/core/st ...

Incorporate hover and click functionality to the dropdown button using JQuery

Recently, I implemented hover and click events to trigger the opening of a dropdown content The functionality is mostly working as expected but there is a slight issue When hovering over the element, the content opens and closes properly However, on the ...

FlexNav excluding

I have implemented FlexNav for my website navigation. The demo I used sets the width of top-level menu items to 20%, which works well with five menu items. .flexnav li { . . . width: 20%; } However, in my menu, the text lengths of the top ...

How to ensure a table in MaterialUI always maintains full width without requiring horizontal scrolling in CSS?

After attempting to allocate each widthPercent value on the TableHeader so they sum up to 100%, I am still experiencing the presence of a scroll bar. I have tried setting fixed widths for each column, but this results in excess space on the right side dep ...

Modification in background when PNG image is hovered upon

Having an issue in Chrome that doesn't occur in Firefox. When hovering over a PNG within a carousel plugin or dragging an element with Jquery, the hover image briefly distorts the background. Looking for a solution to improve user experience. Let me k ...

Is it possible for 'will-change' to achieve the intended outcome when implemented using the Web Animations API?

Google recommends: Google suggests that if an animation may occur within the next 200ms [...] it's a good idea to use will-change on elements being animated. In most cases, any element in your app's current view that you plan to animate should ...

Difficulty in vertical alignment of inline-block elements

Greetings, I am currently working on creating a Resume in HTML. However, I seem to be facing an issue with the inline-block property as the two div elements that should be placed next to each other are not displaying as expected - one of them appears sligh ...

Create a simple carousel using only vanilla JavaScript, without relying on any external plugins

Currently, I am working on implementing a carousel using plain JavaScript without the use of any plugins. My goal is to have previous and next buttons that will control the sliding images. var firstval = 0; function ...

Tab button that can be easily printed

I'm currently facing a challenge with my HTML code on my website. I have 5 tabs already set up, but I want to add one that redirects users to a printable page that opens the print menu specific to their browser. It seems like there might be an issue i ...

Achieving the perfect vertical alignment of navigation buttons alongside a responsive image

Is there a way to ensure that the button always vertically aligns in the middle of the image responsively? I've managed to make the image responsive using .img-responsive, but I'm having trouble keeping the arrow centered on the image at all time ...

Animate.css does not function properly when loaded locally

I'm currently using a Flask server to host an HTML file for testing purposes. Within the head of this HTML file, I have linked to a locally stored animate.min.css file (<link rel="stylesheet" type="text/css" href="{{ url_fo ...

Adjust the height of an element using CSS based on the height of another

Is there a way to have two divs per row, where the second div always displays its full content and the height of the first div matches the height of the second div? If the content in the first div exceeds the height, it should be scrollable. I've atte ...

Position on the chart in the Highcharts

I have developed 2 highcharts in the code below: <div> <p id="container"> </p> <p id="cont"> </p> </div> I specified the width and height as follows: $('#cont').highcharts({ char ...

The presence of the WordPress admin bar results in extra whitespace on the page, while including

In the process of creating my very first custom WordPress theme, I encountered an issue with whitespace at the top of the body. This was caused by calling wp_head(); in header.php and including the header on each page. To offset this whitespace, I added a ...

What are some effective strategies for incorporating multiple Themes into an AngularJS project?

Currently, I am in the process of working on a project that involves utilizing AngularJS, UI Bootstrap, and Sass. The next step is to incorporate different themes that can be selected by the user. While I have successfully implemented the ability to apply ...

Vue-Router functions only on specific routes

While my vue-router correctly routes the URL for all menu buttons, it's not displaying each Vue component properly. You can see a demonstration here. Here is a snippet of my HTML (using Vuefy) <div class="navbar-start"> <a ...

Creating a centered arrow using CSS within boxes

Here is the CSS class that I have applied to my divs: .rightarrow{ width: 0; height: 0; border-style: solid; border-width: 10px 0 10px 20px; border-color: transparent transparent transparent #aaaaa9; } This is ...

What can be done to prevent inputs from shifting when resizing a browser window?

I am struggling to align checkboxes and text on a PHP form I am creating. No matter what I try, they end up misaligned when the browser is resized. Any suggestions on how to solve this alignment issue without changing the format of the rest of my page wou ...

Issue with :visited pseudo-class not functioning as intended

My code includes all four basic pseudo-classes, and they all seem to be working fine except for the :visited pseudo-class. The color property doesn't function properly, and the background property appears to be inactive. I'm not sure what the iss ...