Clicking will cause my background content to blur

Is there a way to implement a menu button that, when clicked, reveals a menu with blurred content in the background? And when clicked again, the content returns to normal?

Here's the current HTML structure:

<div class="menu">
  <div class="line"></div>
  <nav>
    <ul>
      <li><a target="_parent" href="">A</a></li>
      <li><a target="_parent" href="">B</a></li>
      <li><a target="_parent" href="">C</a></li>
      <li><a target="_parent" href="">D</a></li>
    </ul>
  </nav>
</div>

The CSS styling used:

$square: 50px;
* {
  @include box-sizing(border-box);
}
body {
  background: #111;
  font: 300 14px Consolas, system, monospace;
  color: #fff;
}
.menu {
  position: fixed; 
  height: $square;
  width: $square;
  cursor: pointer;
  top: 0;
  right: 0;
  background: #fff;
  @include transition(all 250ms ease-in-out);
  z-index: 100;
  overflow: hidden;
  nav {
    position: fixed;
    left: 50%;
    top: 50%;
    @include transform(translateY(-50%) translateX(-50%));
    opacity: 0;
    @include transition(all 250ms linear 250ms);
    pointer-events: none;
    ul {
      list-style-type: none;
      padding: 0;
      li a {

        display: block;
        padding: 10px;
        text-decoration: none;
        color: #000;
        text-align: center;
        &:hover {
          background: #000;
          color: #fff;
        }
      }
    }
  }
  .line {
    height: 5px;
    width: $square - 10;
    background: #000;
    position: absolute;
    top: ($square/2)-(5/2);
    left: ($square - ($square - 10))/2;
    @include transition(all 250ms linear);
    &:after, &:before {
      content: ' ';
      height: 5px;
      width: $square - 10;
      background: #000;
      position: absolute;
      @include transition(all 250ms linear);
    }
    &:before {
      top: -10px;
    }
    &:after {
      bottom: -10px;
    }
  }
  &.active {
    width: 100%;
    height: 100%;
    nav {
      opacity: 1;
      pointer-events: all;
    }
    .line {
      background: transparent;
      &:before {
        background: #000;
        @include transform(rotate(-405deg));
        top: 0px;
      }
      &:after {
        background: #000; 
        @include transform(rotate(405deg));
        bottom: 0px;
      }
    }
  }
}

This JavaScript functionality is included:

$('.menu').click(function(){
  $this = $(this);
  if ($this.hasClass('active')) {
    $this.removeClass('active');
  }
  else {
    $this.addClass('active');    
  }


});

Your assistance on this matter would be greatly appreciated. Thank you.

Answer №1

Check out this demo on CodePen showcasing:

content {filter:blur(5px);

http://codepen.io/simoncmason/pen/ogoPXK

In this example, the content is blurred in the background. Keep in mind that browser support for this feature may not be complete (http://caniuse.com/#search=filter) especially in Internet Explorer.

Alternatively, you can apply an opaque filter for broader support while allowing better browsers to experience the blur effect. Another option is using an inline blurred SVG or implementing a JavaScript library like Blur.js

Answer №2

Check out the demonstration here.

In essence, all you have to do is add a dynamic div (or insert manually) and give it a fixed position with width: 100% and height: 100%, along with a specified background & opacity.

Remember to ensure that this div is positioned outside of the .menu container, as placing it within will cause the .menu contents to inherit the opacity.

Answer №3

For all your stylesheet related inquiries, a great resource to explore is http://css-tricks.com, known for its extensive library.

To achieve the desired blur effect when clicking on the menu and reverting it back to normal upon release, focus on utilizing CSS FILTERS.

If you need a visual demonstration of this technique, check out this helpful JSFIDDLE EXAMPLE I came across in my research.

Incorporate the following snippet into your stylesheet to implement the blur effect:

This specific class (#blurMe) is assigned to the container when the sidebar is open.
-----------------------------------*/
.blurred {
  -webkit-transition: all 0.6s ease;
  transition: all 0.6s ease;
  -webkit-filter: blur(10px);
  filter: blur(10px);
  -webkit-filter: url(#blur);
          filter: url(#blur);
  filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius='10');
}

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 transitions on my jQuery Mobile page are not functioning correctly

I am currently working on a custom MVC structure using Handlebars and jQuery Mobile. To manually manage routing, I have disabled two jQM parameters: $.mobile.linkBindingEnabled = false; $.mobile.hashListeningEnabled = false; These lines disable link bind ...

Is it possible for a table data cell to be nested within another table

Is it possible for a <td> to be a direct child of another <td>? For example: <td class="parent"> <td class="child"> <!-- Some content --> </td> </td> Or is it necessary to always create a new < ...

Deactivating choice options when loading the page according to the MySQL query

I am seeking a solution for disabling certain options in a select input based on entries in a table. Specifically, I want to disable the time option if it has already been added twice to the table. For instance, if there are two entries for 1/18/2017 at 12 ...

The external javascript file is unable to recognize the HTML table rows that are dynamically inserted through an AJAX request

I have a situation where I'm pulling data from an SQL database and integrating it into my existing HTML table row. Here's the code snippet: Using Ajax to fetch data upon clicking analyze_submit: $(document).ready(function(e) { $('#anal ...

What is the best way to retrieve the first item in owl carousel's content?

I need help creating a slider with two sections: top and bottom. My goal is to display the content from the bottom slider on the top slider. I tried adding a class to the first item element, but it didn't work. If anyone knows how to target the first ...

Sort the array in alphabetical and numerical order while meeting a specific condition

In my code, I am attempting to sort an array based on two conditions. Specifically, I need to ensure that Pos 10 comes after single digits and follows a specific order after that. Initially, I tried to prioritize strings containing the word first, but whe ...

The local() function in CSS @font-face is limited to finding only the "regular" and "bold" font styles, not others

Recently, I added some new fonts (specifically Roboto) to my Linux Ubuntu PC and wanted to incorporate them into my CSS using the @font-face rule. However, I encountered an issue when specifying different font weights within the src: ; property as shown in ...

Find an element within an array in a separate JavaScript file (leveraging AngularJS)

I am new to AngularJS and decided to create a custom map with my own markers that I defined. To do this, I started by creating a JavaScript file containing an array: var myMarkers=[{ method1='..', methode2='..' },{ method1=&a ...

Set the container width to a fixed size, then center a div within it with a dynamic width. Ensure that the left and right div

Arrange three columns with a fixed combined width. The center column will have dynamic content, while the left and right columns should fill out the remaining space equally. For example, see this demonstration: http://jsfiddle.net/htKje/ <div class="c ...

Linking JSON Data to a Data Table

I have integrated DataTable into my project and I am working with a JSON data source stored in a variable called 'myJson'. This JSON data includes fields for first name, last name, and contact type, organized as follows: var myJson = "[ ...

Tips on incorporating several class names into Next.js elements

My current challenge involves an unordered list element with the following structure: <ul className={styles["projects-pd-subdetails-list"]}> {detail.subdetails.map((sub) => ( <li className={styles[ ...

Extract the last word from a string, filter out any special characters, and store it in an array

Here is the content of the xmlhttp.responseText: var Text = "FS2Crew A320 Checklist_1""FS2Crew Flight Crew A320 Main Ops Manual_1""FS2Crew Flight Crew A320 Main Ops Manual_10""FS2Crew Flight Crew A320 Main Ops Manual_11&q ...

Obtaining Beverage Overall with Loop

I am currently using a function to calculate the total of each drink, with a total of 5 drinks: var totalEstimate = 0; var locoCost = 0; var blackCost = 0; function calcLoco() { totalEstimate -= locoCost; locoCost = docume ...

Utilizing ScrollView Component in React Native

I have developed a simple app that displays a collection of images with titles, resembling a film gallery where all available films can be viewed. However, I encountered an issue when trying to implement the ScrollView element as it does not allow for scro ...

Issue with Ajax calendar extender not displaying full calendar due to being cut off

I've implemented the Ajax calendar extender with my own custom CSS classes. The styles are being applied correctly, but I'm encountering an issue. When the calendar at the bottom of the page opens, it gets cut off at the bottom due to the restric ...

Utilizing Bootstrap to display side by side images at full height

Can someone help me achieve the layout shown in the image below? I want a container that spans full width and height with 2 images and other elements inside. The images should be full-height within the container, but also automatically adjust their width t ...

The slider causing conflicts with widgets and content positioned below it in an HTML layout

When implementing a slider with a fade effect, there seems to be an issue with the placement of widgets on the homepage. The problem arises from the margin-top setting as when images change in the slider, the widgets clash with the slider. During the trans ...

Converting objects to arrays in reactJS

Here is the object structure I currently have: { DepositAmt_0: 133 DepositAmt_1: 455 DepositAmt_2: 123 DepositNotes_0: "some notes " DepositNotes_1: "some comment" DepositNotes_2: "some comme ...

How is it possible that I am receiving two different outputs, with one of them even being undefined

I created a button using Jquery to submit POST data. It sends the value "name" : "kevin" in JSON format. $(document).ready(function() { $('#clickMe').on('click', function() { var data = {}; data.name="kevin"; ...

Enhancing data management with Vuex and Firebase database integration

Within my app, I am utilizing Firebase alongside Vuex. One particular action in Vuex looks like this: async deleteTodo({ commit }, id) { await fbs.database().ref(`/todolist/${store.state.auth.userId}/${id}`) .remove() .then ...