The automatic CSS cookie bar functions smoothly, but could benefit from a small delay

I successfully added a pure CSS cookie bar to my website, but there is a slight issue. When entering the site, the cookie bar is the first thing that appears, and then it goes up and down before settling at the end.

How can I make my cookie bar only go down when I enter the site? I've tried adjusting the animation delay and adding set timeouts, but nothing seems to work!

You can view the original codepen to see what I want to change:

    www.codepen.io/natewiley/pen/uGtcD

Here is my code:

<input class="checkbox-cb" id="checkbox-cb" type="checkbox" />
<div class="cookie-bar">


<div class="message">
This website uses cookies to give you an incredible experience. By using 
this website you agree to the
<div class="buttoncookies-container">
<a style="letter-spacing: 1px;" class="buttoncookies" id="modalcookieslinken" onclick="toggleOverlay()">terms</a>
</div>
</div>

<div class="mobile">
This website uses cookies, 
<div class="buttoncookies-container">
<a style="letter-spacing: 1px;" class="buttoncookies" id="modalcookiesshortlink" onclick="toggleOverlay()">
learn more
</a>
</div>
</div>


<label for="checkbox-cb" class="close-cb">X</label>
</div>

</div>

Here is my CSS:

.cookie-bar { z-index:9996; position: fixed; width: 100%; top: 0; right: 0; left: 0; height: auto; padding: 20px;  line-height:20px; text-align: center; background: #d2c6af; transition: .8s; animation: slideIn .8s; animation-delay: .8s; display: inline-block; }

.mobile { display: none; }

@keyframes slideIn { 0% { transform: translateY(-1000px); }  100% { transform: translateY(0); } }

.close-cb { border: none; background: none; position: absolute; display: inline-block; right: 20px; top: 10px; cursor: pointer; }

.close-cb:hover { color:#fff;; }

.checkbox-cb { display: none;}  

#checkbox-cb:checked + .cookie-bar { transform: translateY(-1000px); }

Answer №1

By eliminating the line in the CSS code that states animation-delay: .8s; you will achieve the desired outcome

Extend the duration of the animation.

animation: slideIn 4s;

Additionally, incorporate a little flair to the animation sequence:

0% {
  transform: translateY(-50px);
}
50% {
  transform: translateY(-50px);
}
100% {
  transform: translateY(0);
}

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

Is it possible to run Next.js 13 with React.js version 17?

Can Next.js 13 be used with React version 17? I upgraded my Next.js to version 13 and encountered a minimum requirement of React version 18, which is not compatible with my codebase. Is it possible to use Next.js 13 with React version 17 instead? ...

Navigate to a new tab using this.router.navigate

Is there a way to redirect the user to a specific page with ${id} opening in a new tab, after clicking a button in an angular material dialog box? I want to leave the dialog box open while querying the new page. Currently, the redirect happens but not in a ...

Updating the organization of the models directory in Loopback

I am looking to update the structure of the models folder. As per the documentation, I can make changes to the json config file which is typically set up like this: { "_meta": { "sources": [ "loopback/common/models/**/*", "loopback/serve ...

When the page is minimized, the alignment of Bootstrap divs becomes distorted

Check out my code on CodePen: http://codepen.io/auble220/pen/rOPBKP. I added media queries in this version: http://codepen.io/auble220/pen/avyZZE. Although it's not too bad, I'm sure there's a more efficient way to achieve this. I attempted ...

Retrieving object information in the constructor using Angular and Typescript

When attempting to access an object's data within a constructor, it results in an "undefined" object. Even though it functions properly in the ngOnInit() function, the data which is about to be reset is required every time the component is initiated. ...

The CSS JSON code I have written is not having any impact on the appearance of my div

<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="styles/common.css"> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script type='text/javascript'> ...

Adjust the colors of the borders upon clicking the button

Hello, I'm attempting to create a function where clicking on one button changes its border color to blue and changes the border color of all other buttons to orange. However, I'm encountering an issue where the border color for the other buttons ...

Ways to reload the page following the submission of a form

I implemented a fade dialog to present a form, and successfully submitted the form using ajax to create a new record in the database. Now, I am facing an issue where I cannot refresh the page after the ajax call finishes. Despite attempting to use JavaScr ...

Discover the best locations within the city using Google's API to search by category

Users will choose a city and a type of place. The desired output is a Google Map showing all places in that city with the selected category. I'm looking to achieve this using Google Maps APIs. So far, I've tried using the Places API but it onl ...

Obtain the dynamic $scope variable within the HTML structure

When creating numerous directives with dynamic scope variables initialized in the link functions, accessing these values within the directive templates can get tricky. For example: // link: function(scope, ele, attr){ scope.key = scope.somevar + 's ...

Automatically generated Dropdown failing to respond to jQuery event

$(document).ready(function() { $('[id^=drop_id]').on('change', function() { selected = $(this).find('option:selected').data('tid') $.getJSON('path/'+selected,function(data){ v ...

Exploring Unanchored Substring Queries in Loopback API

Searching for a solution to implement a basic substring query using the loopback API for a typeahead field. Despite my efforts, I have not been able to find a clear answer. I simply want to input a substring and retrieve all brands that contain that subst ...

Programmatically simulating a click on a link within a Windows Universal Windows Platform (U

I am facing an issue with a code that has multiple items with the same href attribute due to it being an external source. I need help figuring out how to programmatically click on a specific link tag using C# within a WebView or by accessing the source d ...

Dropdown in Bootstrap partially obscured by content on page

I have made some adjustments to my Bootstrap dropdown menu: The dropdown now appears when hovering, rather than clicking The li that triggers the dropdown is still clickable Although the dropdown is functioning correctly, there is an issue where it disa ...

The dropdown login form is malfunctioning on my Wordpress website

After reading various tutorials and guides online, I managed to set up a login screen. You can view the code in my jsfiddle: Jsfiddle. Unfortunately, I am facing issues with making the code function correctly. Being new to Jquery, I might have made a begin ...

Show a particular attribute from an array

My goal is to create a function that displays only minivans from an array of cars when a button is pressed. However, I'm having trouble getting anything to display when the button is clicked, even though there are no errors in the program. Any advice ...

What steps should be taken to rectify open tags or quotes in the source code of CKeditor when a user forgets

When inserting data into MySQL using CKEditor and PHP, I encounter an issue when users input raw HTML containing open quotes or tags. How can I handle this problem? For instance, if a user enters content in the CKEditor source and leaves quotes open, how ...

Is it possible to use AngularJS promises without callbacks?

Typically, when I want to retrieve data asynchronously, I would use the following approach: var promise = $http.get('/api/v1/movies/avengers'); promise.then( function(payload) { $scope.movieContent = payload; }); This scenario is quite ...

Effortlessly inserting and posting data into a database with Laravel, Bootstrap Modal, and Ajax

My issue is that I am unable to retrieve the value of a textarea input in a Bootstrap modal using Input::get(), as it returns null. The submit button and text input in my view: <button type="button" class="btn btn-danger" onclick="customModalSubmitF ...

optimal application of css with jquery

I have a question about using jQuery to set the padding of a class or id. I am able to successfully change the height of an element with this code: $('.menu').css({ height: '90px' }); But now, I need to apply a specific CSS rule in jQ ...