Gliding along a div and concealing it out of view, making it seem like it has disappeared

I attempted to slide down the ".preloader" div after a 2-second delay using JQUERY, but I couldn't get it to work as expected. I didn't want to use a toggle button for this effect. I also experimented with creating an animation using @keyframes, but encountered an issue where the div extended beyond the page boundaries and triggered a scrollbar, revealing that the div was actually positioned below the HTML page content.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  background-image: url('background_image_one.jpg');
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
}

<!-- Other CSS styles-->

.preloader {
  background: #000823 url("bold-preloader.gif") no-repeat center center; 
  min-height: 100vh;
  height: 100vh;
  width: 100%;
  position: fixed;
  z-index: 100;
  animation: slide 4s ease-out forwards;
}

@keyframes slide{
  0% {}
  
  50%{
    transform: translateY(0px);
    overflow: hidden;}
    
  100%{
    transform: translateY(100vh);
    overflow: hidden;
  }
}

While observing the snippet, you can notice that when the div slides down, it causes additional space below the main body of the page.

https://i.stack.imgur.com/WAmqM.png

Answer №1

Instead of shifting the element's position upward, causing it to still occupy space and create a scroll bar as it moves off-screen, you can instead scale it down to 0 in the Y direction by adjusting the transform-origin to the bottom of the page:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  background-image: url('background_image_one.jpg');
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
}



.container {
  
  width: 50%;
  display: flex;
  justify-content: center;
  align-items: center; 
}

.card {
  transform-style: preserve-3d;
  background-color: rgba(0, 0, 0, 0.5); 
  border: white;
  border-style: solid;
  min-height: 60vh;
  width: 35rem;
  border-radius: 30px;
  padding: 0rem 5rem;
  box-shadow: 0 20px 20px rgba(0, 0, 0, 0.2), 0px 0px 50px rgba(0, 0, 0, 0.2);
}

.avatar {
  min-height: 35vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatarimg {
  width: 40rem;
  z-index: 2;
  transition: all 0.75s ease-out;
}


.info h1 {
  font-size: 3rem;
  transition: all 0.75s ease-out;
  display: flex;
  justify-content: center;
  color: white;
}
.info h3 {
  font-size: 1.3rem;
  padding: 2rem 0rem;
  color: #585858;
  font-weight: lighter;
  transition: all 0.75s ease-out;
}
.sizes {
  display: flex;
  justify-content: space-evenly;
  transition: 0.5s ease-out;
  padding-bottom: 2rem;
}
.sizes button {
  /* padding: 0.5rem 2rem; */
  box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-weight: bold;
  width: 100%;
  padding: 1rem 0rem ;
  background: #f54642;
  border: none;
  color: white;
  border-radius: 30px;
  font-weight: bolder;
  margin: 1rem;
  
}
button.active {
  background: #585858;
  color: white;
}
.purchase {
  margin-top: 5rem;
  transition: all 0.75s ease-out;
}


/* My Custom Buttons Here */
input[type="text"], input[type="password"] {
  border: none;
  border-bottom: 0px;
  background: rgba(255, 255, 255, 0.2);
  color: whitesmoke;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  outline: none;
  height: 40px;
  width: 100%;
  font-size: 16px;
  transition: all 0.75s ease-out;
}

.forminput p {
  font-size: 18px;
  color: white;
}

.forminput {
  padding-bottom: 3rem;
}

.preloader {
  background: #000823 url("bold-preloader.gif") no-repeat center center; 
  min-height: 100vh;
  height: 100vh;
  width: 100%;
  position: fixed;
  z-index: 100;
  animation: slide 4s ease-out forwards;
  
}

@keyframes slide{
  0% {}
  
  50%{
    transform: scaleY(1);
    overflow: hidden;
    }
    
  100%{
    transform: scaleY(0);
    transform-origin: 0 100vh;
    overflow: hidden;
  }
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3d Card Effect</title>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="./style.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
    

</head>
<body>
    <div class="preloader">
    </div>

    <div class="container">
        <div class="card">
            <div class="avatar">
                <div class="circle"></div>
                <img src="./userAvatar.png" alt="avatarimg" class="avatarimg">
            </div>
            <div class="info">
                <h1 class="title">Log In</h1>
                
                <div class="forminput">
                    <p>Email:</p>
                    <input type="text" name="" placeholder="">
                    <p>Password:</p>
                    <input type="password" name="" placeholder="">
                </div>
                </div>
                <div class="sizes">
                    <button>Login</button>
                    
                    <button>Register</button>
                </div>
            
        </div>
    </div>
</div>
    <script src="./app.js"></script>
</body>
</html>

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

Adjust the input dimensions to match the length of the text upon loading

I have a jQuery code that is supposed to test the length of text in an input box when the page loads and adjust the size of the input box accordingly. However, I seem to be encountering some issues with my current approach: $("#emailSubject").attr('s ...

Cannot get the before-leave transition JavaScript hook to function properly in Vue.js

I am facing an issue with my variable, transitionName, in the beforeLeaveHook function. Despite attempting to change it to 'left', the value remains stuck at 'right'. Any assistance on resolving this matter would be greatly appreciated. ...

Having trouble with the parent folder functionality in JavaScript?

I am facing a challenge with my website's structure as I have an old setup that needs to be updated. http://localhost/enc/pdfs/ : This directory contains some html files that are uploaded via ajax to be displayed on a tabbed div using: var Tabs ...

Adding the "input-invalid" class to the input doesn't take effect until I click outside of the input field

When the zipcode field is updated, an ajax call is made. If there are no zipcodes available, I want to mark it as invalid by adding the "input-invalid" class. However, the red border validation only appears when clicking outside of the input field. Is ther ...

Encountering Issues with Formatting InnerHtml Text using RegEx

Technology: React.js I have been working on a custom function in JavaScript to highlight specific words within a code block. The function seems to be functioning correctly, but the highlighting isn't staying after the function is completed. Any ideas ...

I am facing an issue with Angular where the $http.get method is

It seems like there must be a small oversight causing this apparently simple problem. I have a function that interacts with the Spotify API to search for an artist. I know that by accessing the corresponding route using a standard URL, a result is returne ...

Ways to access the properties of an HTML element with JQuery

Can anyone tell me how to extract the value from a specific HTML element using JQuery? For example: <span id="45463_test"></span> (the proper tags need to be used for the code to work correctly) Specifically, I am looking to retrieve the va ...

Having trouble with material-ui installation in React, Redux, and React-Router project

Guide: https://i.stack.imgur.com/k1UMV.png Due to using redux and react router, incorporating MuiThemeProvider at the top of the chain is a bit challenging. What would be the most effective method to integrate this particular library? This is my ReactDO ...

Ensuring that md-select(s) created through ng-repeat are linked to the same model

<div ng-repeat="(key, value) in dataSet | groupBy: 'partner.partnerName'"> <md-select ng-model="userName" placeholder="{{ key }}" class="partnerUser" > <md-option >{{ key }} </md-option> <md-option ng-repe ...

Exploring the power of ElasticSearch alongside Mysql

As I plan the development of my next app, I am faced with the decision between using NoSQL or a Relational Database. This app will be built using ReactJS and ExpressJS. The data structure includes relational elements like videos with tags and users who li ...

Activate video playback when scrolling, but ensure it only occurs one time

I've encountered an issue with my script that is meant to play a video when it reaches a certain position on scroll. The problem is, if the video is paused and scrolling continues, it starts playing again. I attempted to use just one scroll function b ...

What are the steps for retrieving data on the server side by utilizing a token stored in localStorage?

Currently, I am diving into the official documentation for Next.js and utilizing the App router. On the data fetching patterns page, it explicitly states: Whenever possible, we recommend fetching data on the server To adhere to this recommendation, I cr ...

Nested Tab Generation on the Fly

My goal is to create dynamically nested tabs based on my data set. While I have successfully achieved the parent tabs, I am encountering an issue with the child tabs. Code $(document).ready(function() { var data1 = [["FINANCE"],["SALE"],["SALE3"]]; var da ...

Tips for implementing an ajax request in SharePoint 2013

Currently, I am working on developing a custom web part within SharePoint 2013 that requires an ajax call. Here is how I am attempting to achieve this: Within my CafeteriaWebPart.ascx, I have included the following code snippet: <%@ Assembly Name="$S ...

Conceal Element without Eliminating from the Design

Need a solution: I have specific icons to display for certain elements, but not all. However, when hiding the icon, I want the spacing of the element to stay consistent. Is there a method to conceal an image within an element while preserving its allocat ...

Craft CMS contact form with an option to subscribe to our MailChimp newsletter

I'm currently working on setting up a contact form with a subscribe button in Craft CMS v2 to allow users to add their details to a MailChimp mailing list. Although I've been using the MailChimp Plugin and the Contact Form Plugin, integrating the ...

Navigate to the specified location using AJAX

When I update a comment using AJAX, I want to automatically scroll down to the updated comment: $("#aggiorna").click(function(){ var value = $("#id").val(); var dato = $("#comment_edit").val(); var dato1 = $("#user_id").val(); var dato2 = ...

JavaScript - issue with event relatedTarget not functioning properly when using onClick

I encountered an issue while using event.relatedTarget for onClick events, as it gives an error, but surprisingly works fine for onMouseout. Below is the code snippet causing the problem: <html> <head> <style type="text/css"> ...

CSS code to modify background color upon mouse hover

I am currently working on creating a navigation menu. Check out the code snippet here: http://jsfiddle.net/genxcoders/ZLh3F/ /* Menu */ .menu { height: 100px; float: right; z-index: 100; } .menu ...

Exploring the Benefits of Using JSON in AJAX Requests

Can you help me determine the best way to extract data from a php page using ajax in the form of a json array? Here is an example code snippet: $.ajax({ type: "get", url: "assets/update_cart_user_fstore.php", data: up, cache: false, su ...