CSS animation displays on top as it runs

My issue involves animating 2 blinking eyes that appear on top of my navigation bar when I scroll the page. Surprisingly, this doesn't happen without the animation. How can I ensure that the animation runs smoothly under the navigation bar? I have tried z-index but it hasn't worked for me yet. To showcase the problem, here's a Link

Answer №1

Your code has been modified in the following way:

<script setup>

</script>

<template>
<div class="nav">
  navigation bar
</div>
<div class="face">
<div class="eyes">
   <div></div>
   <div></div>
</div>
</div>
<div class="content">
  
  </div>
</template>

<style>
 @keyframes blink {
    0% {transform: scaleY(0.1) scaleX(1.4);}
    5% {transform: scaleY(1) scaleX(1);}
    10% {transform: scaleY(0.1) scaleX(1.4);}
    15% {transform: scaleY(1) scaleX(1);}
  }
  .face {
    height: 100px;
    background-color: black;
    padding: 20px;
    margin: 50px 100px;
  }
  .eyes {
    display: flex;
    flex-direction: row;
    margin: 0 100px;
    justify-content: space-between;
    
  }
  .eyes div {
    width: 15px;
    height: 20px;
    background-color: white;
    border-radius: 5px;
    animation: blink 3s linear 0.0001s infinite;
  }
  .nav{
    background-color: pink;
    padding: 10px;
    position: fixed;
    top: 0;
     left: 0;
     right: 0;
    z-index: 100;
  }
  .content {
    height: 1000px
  }
</style>

In this version, a z-index: 100 has been included to ensure the nav bar remains at the forefront.

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

Use Powershell to extract the content of a text box from a webpage and store it in a text file

I am currently developing a script that will navigate to a specific webpage and interact with it by clicking a run button to calculate a value. The calculated value will then be displayed in a read-only text area identified by the id="result Console". Here ...

The functionality of jQuery's slideUp and slideDown is not performing as intended

I am trying to implement a feature where a div element will hide and show based on a checkbox selection using jQuery's slideUp() and slideDown() functions. The structure of my div is as follows: <div class="parent"> <label class="childLe ...

What strategies can I implement to safeguard against harmful Vuex mutations?

My Vue SPA quiz app utilizes a Vuex store to keep track of the number of correctly answered questions by users. This data is then transferred from the store to my server for storage in the database. However, I am concerned about the security risks. Is it ...

How can the Bootstrap Jumbotron element be adjusted to perfectly fill the width of the screen?

Currently, I'm utilizing a jumbotron element on my website and aiming to make it fluid in order to adapt and fit the entire jumbotron to the screen width. However, I seem to be facing difficulty when attempting to increase its width. Below is the cod ...

Fascinating CSS rendering glitch observed on zooming in: all browsers create a noticeable gap between containers except for Firefox

I'm experiencing a rather intriguing and peculiar issue with css styles when zooming in and out on the browser. Specifically, I've created a material ui card where the background-color changes upon clicking with an animation effect. The animati ...

Replacing HTML elements with PHP's str_replace function

Looking for help with code: $newphrase = str_replace('href="/Css/IE6.css"', 'href="http://www.company.com/pgrddedirect/iefix.css"', 'href="/Css/IE6.css"'); I am trying to use PHP's DOM to search an HTML file and modify ...

The mouseover and mouseleave functions remain active even during window resizing

I wish to create a dynamic menu that appears when hovering over a user, but only if the window size is above 977 pixels. Take a look at my code below: $(document).ready(function() { $(window).on("load resize", function(event){ var windowS ...

State in Vuex is not kept intact after redirection to another page

Inside my Vue.js application, I have created a method for logging in users. This method sends a POST request to the server with the username and password, stores the returned data in Vuex store, and then redirects the user to the home page: login: func ...

Troubleshooting issue with refreshing selectpicker in Bootstrap-select and Vue.js

Incorporating the bootstrap-select plugin (found at ) into a ruby on rails app with Vue.js as the javascript framework has been my latest project. The goal is to have two select options where one selects a category and the other displays all available tea ...

Obtain the URL link from Unsplash where the picture is sourced

As I work on a website, I incorporate a link () to display a random photo. However, the photo refreshes periodically and upon loading the site, all that is visible is this default link: . Is there a method to extract the actual source like so: "". Althou ...

Bringing in JavaScript files from a Bootstrap theme to incorporate them into a Vue3 application

Incorporating Bootstrap 5, a HTML theme with a CSS bundle file, and separate JS bundle files (main JS bundle file and plugin bundle file) containing Bootstrap code base + custom template features into a Vue 3 project is my current objective. I aim to utili ...

Guide to positioning a toolbar within an element when hovering over it in HTML with the help of JQuery

function attachMenuBar() { $('body').on('mouseover mouseout', '*:not(.printToolBar)', function (e) { if (this === e.target) { (e.type === 'mouseover' ? setMenuBox(e.target) : removeMenuBox(e.t ...

Troubleshooting an Issue with CSS Sliding Doors

I'm having trouble getting the right image to show on my website. The left side of the image is fine, but I can't figure out how to make the right one appear. As a HTML/CSS beginner, I'm still learning the basics. For more information, vis ...

Organizing lists with HTML unordered lists

Is it possible to sort list items by numbers within a strong tag using JavaScript code? The current code successfully sorts the numbers, but removes them from the div tag. (The JavaScript code used below is for sorting by Name and works properly when &apos ...

VueJS is unable to identify the variable enclosed within the curly braces

I recently started learning VueJS and I've hit a roadblock. My goal is to display a variable, but for some reason, instead of seeing the product name, all I get is {{product}} Here's the HTML code I'm using: <!DOCTYPE html> <html l ...

What is the best way to style the currently selected option element in a select dropdown?

I am trying to change the font color of specific option elements within a select dropdown by adding style="color: #D4D4D4". When I apply this style directly to an option element like <option value="TEST" style="color: #D4D4D4">TEST</option>, it ...

Rendering lists in Vuejs2 with computed properties for filtering

I'm struggling with list rendering and filtering data using computed properties. Instead of statically setting the row.age value, I want to filter based on filterKey. Any guidance on how to achieve this? I'm having trouble understanding it. He ...

Submitting numerous data fields using a post AJAX call

I have roughly 143 form fields including text, textarea, and select options that I need to send via an AJAX post request. Is there a way to achieve this efficiently without manually adding each field to the query? Here is how I've set things up: Usi ...

Click the button in Javascript to add new content

I am currently experimenting with JavaScript to dynamically add new content upon clicking a button. Although I have successfully implemented the JavaScript code to work when the button is clicked once, I would like it to produce a new 'hello world&ap ...

Retrieve the row index in PHP after loading data onto a web page

I have been utilizing PHP to retrieve data from a MySQL database and showcase it within a DIV on a webpage. The information I am retrieving pertains to a list of tasks, and I would like users to have the ability to delete a task once it has been completed. ...