What could be causing the blur effect to not show up on the dropdown menu?

In designing the mobile version of my website, I encountered an issue with applying a blurred background to both the header and menu-content. Strangely, when one element is blurred, the other loses its blur effect. Below are snippets of CSS, HTML, and JS for implementing a dropdown menu:

@media screen and (max-width: 767px) {
    .header {
        position: fixed;
        width: 100%;
        z-index: 2; 
        background-color: rgba(34, 35, 37, 0.8); 
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 20px;
        transition: all 0.3s;
    }
    
    .menu-content {
        position: absolute;
        top: 100%; 
        left: 0;
        right: 0;
        background-color: rgba(34, 35, 37, 0.8);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.2); 
        overflow: hidden;
        transition: max-height 0.5s ease;
        max-height: 0; 
        z-index: 3;
    }

<body>
    <div id="particles-js"></div>
    <header class="header">
        <a href="/" class="josefin-sans-header">OMNIA</a>
        <div class="menu-button" onclick="toggleMenu()">
            <div class="menu-line top"></div>
            <div class="menu-line middle"></div>
            <div class="menu-line bottom"></div>
        </div>
        <nav class="menu-content" id="menuContent">
            <div class="menu-item pt-sans-regular-options" id="premium-option">Premium♾️</div>
            <div class="menu-item pt-sans-regular-options">Commands</div>
            <a href="https://discord.com/api/oauth2/authorize?client_id=595589012270612508&permissions=8&scope=bot%20applications.commands" class="menu-item pt-sans-regular-options" target="_blank">Invite Bot</a>
            <a href="https://discord.gg/DajNSdYq" class="menu-item pt-sans-regular-options" target="_blank">Help</a>
            <div class="menu-item pt-sans-regular-options">Authorization</div>
        </nav>
    </header>    
    <section class="home geologica-title">
        <div class="content">
            <h2> OMNIA </h2>
        </div>
    </section>
    <div class="additional-rectangle">
        <div class="server-stats">
            <div class="server-count-text geologica-title" id="server-count-text">Loading...</div>
            <div class="avatars" id="server-avatars">
                <div class="avatar"></div>
                <div class="avatar"></div>
                <div class="avatar"></div>
                <div class="avatar"></div>
                <div class="avatar"></div>
            </div>
        </div>
    </div>
    <div class="additional-rectangle2">
    </div>
</body>

function toggleMenu() {
    var menuButton = document.querySelector('.menu-button');
    var menuContent = document.getElementById('menuContent');
    menuButton.classList.toggle('x-active');
    
    if (menuContent.style.maxHeight) {
    menuContent.style.maxHeight = null;
    } else {
    menuContent.style.maxHeight = menuContent.scrollHeight + "px";
        }
    }

My intention was to have both the header and menu-content elements blurred. Any insights on how to achieve this would be greatly appreciated.

Answer №1

When attempting to achieve a stylish blur effect on both your header and menu, but encountering issues with only one cooperating, it's often due to how the layers of blur stack upon each other.

.header::after, .menu-content::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
backdrop-filter: blur(10px);
z-index: -1;

}

Remember to ensure that your .header and .menu-content are set to relative positioning so these pseudo-elements have a reference point for placement.

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 expand or collapse parent elements using a combination of javascript and jquery?

I apologize for my limited experience with JavaScript. I am currently working on updating some outdated online documentation that is based on framesets to HTML5/responsive design. The writers use a desktop-based CMS to input each "topic" and then the CMS p ...

"Error encountered: Module not found - Issue resolving module" while using signrequest-client in Angular

I've been attempting to integrate the signRequest API into my angular application. To do so, I first installed the signrequest-client using the following command: npm install signrequest-client --save Following this installation, I included the Ja ...

How can the color of glyphicons be adjusted within an AngularJS ng-class that is constantly changing?

I am currently facing an issue with my function called lessThan(a,b) that checks if "a" is less than "b" and returns a boolean value. I have added a glyphicon to a form to display a check mark when true and an X when false, but I can't get the colors ...

Using Mongoose's `findOne` along with `save` will generate a fresh object and activate

I am currently using MongoDB 4.4.10 (due to limitations on Synology). My stack includes Express, Mongoose, and UniqueValidator 3.0.0 which seems to be the main suspect in my issue. The problem arises when executing the following code: router.get('/te ...

How can I resolve the issue of "require is not defined" in the code?

tag, you can find the following code snippet: Upon importing the 'mysql' module, an issue persists in the browser matching the error indicated by the title. Starting my journey into programming, I aim to develop a membership registration functio ...

There was a SyntaxError that was not caught, due to an invalid left-hand side expression in a

I'm feeling really lost and would appreciate some help. Can someone explain why...? true++ This code snippet produces... "Uncaught SyntaxError: Invalid left-hand side expression in postfix operation" However, if we try... undefined++ W ...

Vuetify: Dynamic v-select options based on user selection

Here's a codepen I created as an example: https://codepen.io/rasenkantenstein/pen/qBdZepM In this code, the user is required to select a country and then choose cities only from that selected country. The data of people is stored in an array behind t ...

Display the QWebEngineView page only after the completion of a JavaScript script

I am currently in the process of developing a C++ Qt application that includes a web view functionality. My goal is to display a webpage (which I do not have control over and cannot modify) to the user only after running some JavaScript code on it. Despit ...

Deactivating Touchable Opacity Sounds in React Native

Currently, I am in the process of developing an application, utilizing TouchableOpacity instead of a button. I am looking to disable the auditory feedback that occurs when the TouchableOpacity component is pressed. <TouchableOpacity activeOpacity={1} to ...

Restrict user uploads to a maximum of 5 posts per minute using Jquery

Recently, I have implemented this jQuery/AJAX code snippet: var uploaded=0; if (uploaded!=0) { setInterval(function() { uploaded--; }, 60000); alert(uploaded); } $(".UploadMSub").click(function(event){ event.preventDefault(); ...

Tips for assigning a postgres query to a variable when working with node.js, integrating Discord bot with postgres

My friend and I have been brainstorming a business idea that involves using Discord as our platform. While I am somewhat new to coding, I do have some knowledge in Discord.js, Java, and HTML. Here’s the plan: We will have a website where users can purch ...

Challenges Arising from the Reflection of Vectors in Particle Collisions

Could there be a potential math error in my particle collision simulation that I created? You can find the simulation here. The issue seems to be with the separation of particles during collision resolution. Below is a snippet of the code where particles ...

Eliminating blank or unspecified elements within an array

I'm struggling to remove empty or undefined elements from an array. Here's the code I've tried: function clean(item) { for (var i = 0; i < item.length; i++) { if (item[i] === undefined || item[i] == "") { item.spl ...

Inquiries about creating collapsible content using html, css, and javascript

I have been exploring collapsibles and noticed that many of them use extra code that seems unnecessary or confusing. I decided to create a simple one based on my logic, but it's throwing an error: app.js:4 Uncaught TypeError: Cannot read property &apo ...

What is the best way to ensure the image and card maintain the same size ratio in React Bootstrap?

One of the challenges I encountered involved a vertically aligned card group containing a card with an image: https://i.stack.imgur.com/w9Jkf.jpg This is the React code snippet that was causing the issue: import React from 'react'; import { ...

Utilize HTML5 and Javascript to easily upload files from your desktop through the drag and drop feature

I have created a drag and drop functionality for uploading images from the desktop to the browser. When I drop the image inside the designated box, I can view the image details in the browser console: File { name: "deam230mthumb.jpg", lastModified: 119464 ...

The Authorization header in POST and PATCH fetch requests is stripped by Typescript

I have developed an API in C# that utilizes JWT tokens for authorization. On the frontend, I store these tokens in local storage and retrieve them when making a request. GET or DELETE requests work seamlessly, as I can verify through console.log() that t ...

Error in Node.js and jdbc: Uncaught type error - unable to access property 'url' as it is undefined

Hey there, I'm currently diving into the world of nodejs and JavaScript. I've embarked on a basic example involving MySQL connectivity with nodejs, utilizing an npm jdbc package. However, upon running the code snippet below, I encountered an exce ...

Avoid nesting ternary expressions when possible - consider alternative solutions

I am currently working on a React component that has 4 different states: advisoryResults, results, noResults, and newAccount. While I initially thought about using a ternary expression for this, it turns out that it is not allowed in this case. Can you su ...

Customizing Marker Clusters with ui-leaflet: A guide on changing marker cluster colors

I'm trying to customize the markerCluster color in a non-default way. I've been exploring the API and it looks like the recommendation is to modify a divIcon after creation, possibly like this: var markers = L.markerClusterGroup({ iconCreateFunc ...