What is the best way to blur the background of the login page when the sign-up form appears?

Seeking assistance with creating a blurry background effect when switching from the login section (#login) to the registration form (#id01). How can this be achieved? Any help would be appreciated.

Here is the HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
...

The JavaScript:

<script>
  // Get the modal
  var modal = document.getElementById("id01");

  window.onclick = function (event) {
    if (event.target == modal) {
      modal.style.display = "none";
    }
  };
</script>

The CSS code:

.login-container {
...

Awaiting your response. Thank you!

Answer №1

Add an event listener for click on the modal opener anchor that applies the CSS property filter: blur(5px) to the login container.

Remember to reset the blur back to 0px when hiding the modal.

Demo:

// Access the modal element
var modal = document.getElementById("id01");
var c = document.querySelector('.login-container');
modalopener.addEventListener('click', function(){
  c.style.filter = "blur(5px)";
})
window.onclick = function(event) {
  if (event.target == modal) {
    c.style.filter = "blur(0px)";
    modal.style.display = "none";
  }
};
.login-container {
  margin-top: 5%;
  margin-bottom: 5%
}

/* Other CSS styles */
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <!-- Bootstrap and custom CSS links -->
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous" />
  <link rel="stylesheet" href="static\css\style1.css" />
  <title>Login</title>
</head>

<body>
  <section id="login">
    <div class="container login-container">
      <div class="row">
        <div class="col-md-6 login-form-1">
          <h3>User</h3>
          <form>
            <!-- Login form content -->
          </form>
        </div>
        <div class="col-md-6 login-form-2">
          <div class="login-logo">
            <a onclick="document.getElementById('id01').style.display='block';" style="width: auto" id="modalopener"><span
              ><img src="static/images/signUp.png" alt="Sign Up" /></span
          ></a>
          </div>
          <h3>Admin</h3>
          <form>
            <!-- Admin login form content -->
          </form>
        </div>
      </div>
    </div>
  </section>
  <section id="signup">
    <div id="id01" class="modal">
      <span
        onclick="document.getElementById('id01').style.display='none',document.getElementById('login').style.opacity=1"
        class="close"
        title="Close Modal"
        >&times;</span
      >
      <div
        class="signup-form"
        style="margin-left: auto; margin-right: auto; width: 500px"
        >
        <h3>Sign Up</h3>
        <form>
          <!-- Sign up form content -->
        </form>
      </div>
    </div>
  </section>
  <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/popper.js/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></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

Tips for using multiple Angular directive modules in PprodWant to enhance your Pprod experience by

Currently, I am working on jhipster Release 0.7.0 and our jhipster app has multiple types of directive modules – one for the index page and another for common directives. However, when we run the app on Prod profile, an exception occurs: [31mPhantomJ ...

Incorporate a button within the input field

Looking to customize my search form with the search button on the right side, similar to this: https://i.sstatic.net/lwmig.png Below is the code for my current form setup: <form action="search.php" method="post" class="index-search-form"> ...

Transform the string property extracted from the API into a JSON object

When making a request to an API, the data returned to the front end is in the following format: { name: 'Fred', data: [{'name': '"10\\" x 45\\" Nice Shirts (2-pack)"', 'price' ...

Struggles between ajax asp.net and jquery colliding

Within my project, I have incorporated numerous jquery files. After researching this issue yesterday, I came across a solution. I made the following adjustment: $(document).ready(function () { and substituted it with: function pageLoad() { An issue has ...

What is the best way to extract a portion of a JSON string?

this.on('success', function(file, responseText) { var theID = JSON.stringify(responseText); alert(theID); window.location.href = ('want to put something here'); }); The ...

Utilizing Asp.Net for seamless file uploading with HTML5's drag and drop feature

Struggling to upload a file using HTML5's Drag and Drop (DnD) and File API. Unsure about how to send form data to the server, attempted using XMLHttpRequest but encountered issues. Here is what I have so far: <body> <form id="fo ...

Execute the SQL "function" (or stored procedure?) whenever a database column is queried

Running on MySQL 5.6, I encounter a situation where various "name" columns in the database lack formatting and sanitization upon importation through CSV data dumps by customers each year. This results in names such as Phil Eaton, PHIL EATON, Phil EATON bei ...

What is the mechanism behind the functioning of Vue.js, React.js, and Angular.js?

Here lies a question born out of sheer curiosity. The burning question is: What is the mysterious inner workings of Client-side frameworks? Allow me to elaborate. I have been delving into the depths of javascript for over 5 years now. Yet, one aspect st ...

Discover the best method for sending multiple API requests to Vuex store using Nuxt middleware

I am having trouble figuring out how to make multiple API calls to Vuex store from Nuxt middleware. I have successfully implemented it for a single API call, but I can't seem to get it working for multiple APIs. // middleware/log.js import axios fro ...

Node.js: Array remains undefined despite being logged on the console

My goal is to download a CSV file, read it line by line, and add the split lines (based on ',') to the tmparray. This code successfully prints all the elements in the array. var request = require('request'); var fs = require('fs&a ...

Tips for modifying CSS when a user scrolls beyond a specific div

Currently, I am working on implementing a scroll function that dynamically moves elements based on the user's scrolling behavior. The code I have written works to some extent and successfully moves the elements. However, my goal is to create a list o ...

Searching with RegEx results in a negative value, despite the fact that the specified phrase is clearly within the array

When importing an excel file into Angular using the xlsx library, the file is converted into an object of arrays. Each array represents a row from the excel file, and each item within the array corresponds to a cell in that row. The process for importing t ...

React component not extending to the bottom of the screen

Within my Index.js file, I have created an Index component that includes a navbar and a landing page layout. I aim to have a showcase section taking up 40% of the width, with the remaining 60% dedicated to a react-bootstrap carousel. The Index component sh ...

Ensure the most recently expanded item appears at the top of the TreeView by updating to Mui version

I'm working on a feature where I want to scroll the expanded TreeItem to the top when it has children and is clicked on for expansion. Any suggestions on how to make this happen? ...

The PHP/JavaScript project is constantly reaching out to yourmeme-site.com

I am currently working on a project on my local server that involves sending frequent requests to your-mime-site.com. In this project, I have integrated the following jquery plugins: jQuery jQuery.form jQuery.validate jQuery.ui Aside from the plugins, ...

Is there a way to have the information on the table automatically update based on the selection made in a drop-down menu?

When a user is selected from the combo box, I want the table displaying user data from the database to only show information related to the selected user. I attempted to use an array to store values but was unable to make it work. A Combo Box that allows ...

I could see the Javascript and CSS code manifesting directly onto my HTML page

I've encountered a strange issue with my calendar code where my JavaScript and CSS codes are inexplicably showing up next to the calendar. Does anyone have any insights into why this may be happening? I developed the code in an online HTML/CSS/JS edit ...

The utilization of Ajax requests within the RESTful client is integral to enhancing

Working with a Java RESTful service alongside the consuming client involves data transmission in JSON format. I need to discuss the implementation of 2 requests in the consuming RESTful client. When a button is clicked, a new entity called WalletInfo is g ...

Can the tab button be used to move to the next field?

Is it possible to navigate to the next field by pressing the tab button? If so, how can we achieve this? Currently, I am utilizing Bootstrap classes col-md-6. Thank you! <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4. ...

The art of building websites and applications for the

Greetings to everyone! I am a beginner in the field of web development and I find myself facing some uncertainties. A few weeks ago, I embarked on creating a website using HTML, CSS, and JS but now I'm at a loss for how to proceed. What should be my n ...