What is causing this particular area to remain unaffected by the blur effect?

issue

I followed a tutorial to create a mouse trailer from this video - https://www.youtube.com/watch?v=kySGqoU7X-s. However, when I tried adding text and other elements inside a div, the blur effect just didn't show up. I attempted using z-index but it didn't work... as I am relatively new, I'm not sure what else to try. This is crucial for my portfolio.

CSS

body {
    background-color: black;
    height: 100vh;
    margin: 0rem;
    overflow: hidden; 
}

.text{
    color:aquamarine;
    z-index : 99;
}

@keyframes rotate {
from {
    rotate: 0deg;
}

50% {
    scale: 1 1.5;
}

to {
    rotate: 360deg;
}
}

#blob {
background-color: white;
height: 34vmax;
aspect-ratio: 1;
position: absolute;
left: 50%;
top: 50%;
translate: -50% -50%;
border-radius: 50%;
background: linear-gradient(to right, aquamarine, mediumpurple);
animation: rotate 20s infinite;
opacity: 0.8;
}

#blur {
height: 100%;
width: 100%;
position: absolute;
z-index: 2;
backdrop-filter: blur(12vmax);
} 

JavaScript

const blob = document.getElementById("blob");

window.onpointermove = event => { 
  const { clientX, clientY } = event;
  
  blob.animate({
    left: `${clientX}px`,
    top: `${clientY}px`
  }, { duration: 3000, fill: "forwards" });
}

HTML

<html lang="en">
    <head>
        <title>PORTfolio</title>
        <link href="style.css" rel="stylesheet">
    </head>
    <body>
            <div class="header">

            </div>

            <div class="text">          
                <h1>Found me?</h1>
                <button>Know more then</button>
            </div>
            
            <div>
                <div id="blob"></div>
                <div id="blur"></div>    
            </div>

    </body>
    <script src="script.js"></script>
</html>

Answer №1

Greetings and thank you for visiting SO! In your quest, you were almost there. The key was to set the top:0; property on your blur div to align with the top of the screen.

However, upon doing so, you may notice that the blur and blob appear in front of your text. I recommend adjusting the z-index values, such as setting z-index:-3; for the blob and z-index:-2; for the blur layer.

To summarize:

top:0; and z-index:-2 for the blur z-index:-3 for the blob

const blob = document.getElementById("blob");

window.onpointermove = event => { 
  const { clientX, clientY } = event;
  
  blob.animate({
    left: ${clientX}px,
    top: ${clientY}px
  }, { duration: 3000, fill: "forwards" });
}
body {
    background-color: black;
    height: 100vh;
    margin: 0rem;
    overflow: hidden; 
}

.text{
    color:aquamarine;
    z-index : 99;
}

@keyframes rotate {
from {
    transform: rotate(0deg);
}

50% {
    transform: scale(1, 1.5);
}

to {
    transform: rotate(360deg);
}
}

#blob {
background-color: white;
height: 34vmax;
aspect-ratio: 1;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
z-index:-3;
background: linear-gradient(to right, aquamarine, mediumpurple);
animation: rotate 20s infinite;
opacity: 0.8;
}

#blur {
height: 100%;
width: 100%;
position: absolute;
top:0;
z-index: -2;
backdrop-filter: blur(12vmax);
} 

            <div class="text">          
                <h1>Found me?</h1>
                <button>Know more then</button>
            </div>
            
            <div>
                <div id="blob"></div>
                <div id="blur"></div>    
            </div>

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

The Facebook app is experiencing issues on Chrome, yet is functioning properly on Firefox

Lately, I've ventured into the world of creating Facebook Apps on heroku. After creating a test app and uploading a page with HTML5, CSS, and Javascript, I encountered an issue where the app wasn't displaying correctly in Google Chrome , but work ...

Creating an infinite SVG animation loop using JavaScript

elem = document.querySelectorAll("path"); function task(i) { setTimeout(function() { elem[i].animate({fill: 'green'}, { // timing options duration: 150, iterations: 1 }); }, 150*i); } for(var i=0;i<8;i++){ task(i); } < ...

Using PHP, JavaScript, and Bootstrap to display success or error messages for form fields through AJAX

I am working on a form where users input an 'authorisation code' that is then checked against a database using AJAX and PHP. Currently, the form displays a tick if the code is valid and a cross if it is incorrect. I would like to utilize Bootstra ...

Securing your Angular2 application with TypeScript for enhanced safety

Looking to create a web application using Angular2 with TypeScript. After researching authentication in Angular2, it seems I need to include the following components: index component (public) login component (public) my private component (private) Thes ...

Utilizing the Authorization Header in WebSocket within a React Electron Application

Struggling to establish a connection with a secure websocket that requires Bearer Auth via Header. Despite popular advice, it seems setting headers for WebSockets is not straightforward. How can I achieve this in a React Electron App? Currently using the & ...

Whenever I attempt to start my ReactJS project using the command line with `npm run it`, I keep encountering an error

Encountered an issue with the webpack-dev-server script while working on my project. Ensure that your node.js and npm versions are up to date. If they are, the problem might lie within the reactjs package rather than npm itself. Kindly inform the author ab ...

Facing issues when attempting to link two databases using Express

Encountering an issue while attempting to use two Oracle databases simultaneously. My startup function only executes the first connection try-catch block, but displays the console log connection message of the second try-catch block without actually estab ...

There seems to be a problem with completing the Axios post request in the Javascript Front

My front-end, built with React, is having trouble retrieving data from a third-party API through my Node.js backend. Despite using axios.post request, the response remains undefined and I'm stuck at handling the asynchronous request. It appears that t ...

How to modify checkbox and textarea values in a MySQL database with Jquery

In my MySQL database, I have a textarea and three checkboxes. By default, the textarea value is null and the checkbox values are set to zero (0). When I enter text into the textarea, I am able to update the text value in my database. However, I am facing ...

Analyzing Data for Distributed / External Pages

Our team is currently exploring options for tracking metrics on content we produce for external pages. We are considering various approaches such as creating our own JavaScript, using a tracking pixel, or adapting Google Analytics to fit our needs. We wou ...

How to create custom options in a JavaScriptMVC Controller's event listener?

When working with JavascriptMVC's Controller, they have a unique format for handling events Rather than using traditional jQuery methods $(function(){ $('#tabs').click(someCallbackFunction1) $('#tabs .tab').click(someCallback ...

Backand - How can I display the contents of variables using console.log() within Security Actions?

Is there a way to utilize console.log() in Backand, specifically within the server side functions like those found under Security & Auth > Security Actions? I have checked the Read.me which suggests using 'console.log(object) and console.error(obje ...

Best practice for updating Form.Control text using a custom onChange method

Today, I observed a unique behavior while utilizing a custom onChange in a Form.Control. The text in the field no longer updates when a file is selected. I thoroughly checked the Git documentation HERE, but unfortunately, it does not provide information on ...

Leveraging JavaScript and PHP for fetching image files and generating a downloadable zip folder

Currently, I am in the process of creating a Safari extension specifically designed for imageboard-style websites. One of the key features that I am eager to incorporate is the ability to download all images that have been posted on the site (not including ...

Adjusting the width of the header in Wordpress themes like Genesis and Foodie Pro

Struggling with the header appearance on my website. I want the blue section to be full width while keeping the logo and navigation the same width as the content area (1040px). I'm new to Wordpress and unsure how to make this adjustment. Someone sugg ...

DirectionsLight isn't functioning properly in Three.js

I attempted to add lighting in Three.js, but after updating the display, the light didn't seem to affect my cylinder. I simply copied and pasted the source code from the Three.js documentation Three.js as instructed, but to no avail. Below is the cod ...

A guide on retrieving data from an API and displaying it using AngularJS

REACT $state.saveData= function(productfilter){ var url = CONFIG.apiUrl + '/product'; window.open(url); window.print(url); }; CSS <button onClick="saveData(productfilter)" type="button">Print</button> ...

Bootstrap: adaptable card design

I am currently working on replicating a card design similar to this one from WIX using bootstrap. I encountered 2 issues: Initially, the card only touches the contact bar at full screen. However, as I reduce the size of the screen, the card begins to floa ...

Parsing error: 'Unexpected token' found in JSON while attempting to access an external file

Currently working on implementing backbone for a new project along with underscore, requirejs, jquery, and bootstrap. Things are progressing smoothly as I aim to include static survey question data into one of the data models. { "defaultOptions": { ...

css readonly input textbox not changing background color when set

I've come across an old Classic ASP form that requires additional functionality, and I'm currently using IE11. To address this, I decided to include a doctype like so (even though I'm unsure of its necessity): <!DOCTYPE html> In my C ...