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

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

Can input be styled instead of using a textarea for design?

Within the confines of a PDF's single-line display, I am in need of including text that does not contain new lines. While using an input instead of a textarea seems like the ideal choice, inputs do not naturally support line breaks and utilizing keydo ...

Issue with the Navigation in CSS and jQuery

I'm struggling to understand a problem with the desktop navigation on this website, specifically in Safari on certain pages. The issue seems to only occur on Safari for Windows, Mac Desktop, and Mac Laptop. Interestingly, the navigation works perfect ...

Is there a way to transition an element from a fixed layout position to an absolute layout position through animation?

I am looking to create a dynamic animation effect for a button within a form. The goal is for the button to move to the center of the form, while simultaneously undergoing a horizontal flip using a scale transform. During the midpoint of this animation, I ...

Adapting Bootstrap components based on the screen size: Viewport-driven

Check out our Custom Sizing Solution, designed to offer sizing options tailored to different devices and viewports. Here's what we can do: For small devices, the width will be set at 100% For larger devices, the width will be adjusted to 75% For ext ...

Stop text from being selected across all browsers in Firefox

My current CSS includes: *{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } If you visit http://jsfiddle.net/KyF5x/ and click be ...

Problem with expanding DIV

Currently, I am working on enhancing this page. However, the DIV element containing the overflowing text does not expand to fit the text properly unless the height property is changed from "auto" to a fixed value. Here is the CSS code snippet for referen ...

The problem with floating labels

I have been attempting to incorporate the floatlabels feature from floatlabels, but I am encountering difficulties in getting it to work properly. Here is the sequence of steps I have taken: Firstly, I include the JS file <script src="js/floatlabels. ...

Best practices for arranging several divs with CSS

I am in the process of creating a main header for several web pages I'm working on. The layout I have in mind includes an image, centered text below the image (all to the left of the main header), a main header that I want to be in the center of the p ...

Navigational elements, drawers, and flexible designs in Material-UI

I'm working on implementing a rechart in a component, but I've encountered an issue related to a flex tag. This is causing some problems as I don't have enough knowledge about CSS to find a workaround. In my nav style, I have display: flex, ...

Issue with relative input causing Jquery click event to not fire

Jquery $(document).on("click","[type=text]",function(event) { alert('test'); }); CSS .noWorking:focus{ z-index:100; position:relative; outline:none; box-shadow:0 0 0 1000px rgba(0,0,0,.2); } To ensure the shadow appears on top of all oth ...

CSS - using numbers to create dynamic background images

I am looking to create a design where the background images in CSS display increasing numbers per article, like this example: This idea is similar to another post on Stack Overflow discussing using text as background images for CSS. You can find it here: ...

Excess gap detected in dual-column design

Exploring HTML once again, I'm currently working on creating a 2 column layout that doesn't rely on floats in order to maintain the natural document flow. Most solutions I've come across involve floats or tables, which I want to avoid. I als ...

Is there a way to expand this embedded video so that it spans the entire width of the screen

I have a code snippet with one row and two columns. I would like to embed a video from Vimeo in the first column so that it fills the entire column without any padding. Additionally, I want the two columns to be right next to each other with no space betwe ...

Understanding the fundamentals of positioning elements in CSS as they float on a webpage

Understanding the behavior of float in CSS can be confusing. When floating an element to the left or to the right, it affects how other elements wrap around it. But why do some elements wrap while others don't? For example, when you have a floated im ...

What causes the off-canvas menu to displace my fixed div when it is opened?

Using the Pushy off-canvas menu from GitHub for my website has been great, but it's causing some trouble with my fixed header. When I scroll down the page, the header sticks perfectly to the top, but once I open the off-canvas menu, the header disappe ...

What is the best way to incorporate a jQuery script to make an engaging slideshow on my website?

I've been trying to develop a slideshow similar to the one showcased on this website. First of all: I am using Kompozer. My website is not yet live as I am still in the process of putting it together on my computer. To give you an idea, here is the d ...

Creating dynamic styles with Material-UI's useStyles

Attempting to implement the same logic using material-ui's useStyle feature <div className={'container ' + (state.unlocked ? 'containerUnlocked' : '')}> I thought it might look like this: <div className={`${clas ...

Internet Explorer 9 (IE9) causing CSS dropdown menu to be truncated due

My issue is very similar to the problem described in this post: CSS Flyout menu gets cut off by borders of its container in IE9 The difference in my case is that I need to set the z-index (and position) on the container. You can view my JSFiddle here: h ...

Flex children do not adhere to max-height and max-width properties

There seems to be an issue with setting the max-width and height for flex children. The div is getting squished down to fit its children exactly, possibly due to the styling associated with div .content. It's not clear why this is happening. The divi ...

What is the best way to eliminate extra space at the bottom of glide.js?

Looking for assistance to eliminate the whitespace at the bottom of an image or slider. Can anyone help? Here is a preview of the image: https://i.stack.imgur.com/mEYY3.png If you'd like to take a look, here is the project code link: I had to down ...