Is it possible to have the background blurred, but only specifically behind the overlay?

How can I make the div appear as if it is blurring the background image of the page, even when the position of the div is changed? Also need to ensure it works seamlessly during window resizing.

Answer №1

I found a clever solution that eliminates the need for JavaScript. By utilizing the same background with specific common settings, I was able to achieve the desired effect.

Check out the code on JSFIDDLE

Here is the HTML:

<div class="mydiv">
    <div class='bgblur'></div>
</div>

And here is the CSS:

body {
    background: url('/etc/bg.jpg') no-repeat center center fixed;
    background-size: cover;
}

.bgblur {
    background: url('/etc/bg.jpg') no-repeat center center fixed;
    background-size: cover;
    -webkit-filter: blur(26px);
    -moz-filter: blur(26px);

    position: absolute;
    height: 100%;
    width: 100%;
    z-index: -1;
}

.mydiv {

    position: relative;
    overflow: hidden;

    // These are optional styles
    border: 2px solid black;
    height: 200px;
    width: 200px;
}

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

Troubleshooting problem with displaying HTML content on Internet Explorer 10

My website was developed using jquery with a dynamic coding style. It was functioning properly in IE10 while working from Visual Studio. However, after deploying it to the production server, the entire style seemed broken in IE10. In all other versions o ...

The issue with jqTransform not displaying the select box value on a hidden contact form

Could really use some assistance here and apologize if it's a hassle: Link to contact form To view the contact form, simply click the "Contact" button in the top left corner. The jqTransform jQuery plugin is being used to style it. Initially, it&apo ...

The issue of centering not working with a specified width under the CSS rule `margin: 0 auto

As I was creating sections for a mini "about me" page, I encountered an issue with setting margins in all divs (this one is the most important). Despite specifying widths and heights, I couldn't get margin: 0 auto; to work. body { background: #aaa; ...

Is there a way to apply border-radius to the header of a table in Bootstrap 5?

My use of Bootstrap 5 for styling a table has encountered an issue. Even with the border-radius set on the table-dark class, the thead element's border does not change. I am looking for a way to address this problem. Any suggestions? .table-dark { ...

The placement of a material-ui component at the beginning of the render method can impact the styling of the following components in the hierarchy

After creating some styled components, I noticed that they were not rendering correctly for me. However, when I transferred the code to a codesandbox environment (which had a material-ui button in the template), the components rendered perfectly fine. It w ...

What is the proper way to position elements within a <td> tag?

I am working with Products that have images of maximum size 100px. This means either the width is 100px and the height is less than 100px, or the height is 100px and the width is less than 100px. One side always measures 100px. My goal is to display the p ...

Learn how to use CSS flexbox to easily vertically center items within a container with a full-height background

I'm having trouble with aligning text vertically centered within a box and making sure the background color stretches to full height. HTML: <div class="feature-content"> <div class="feature-visual"> <div class="embed-container"> ...

Prevent the border from shrinking upon being clicked

I'm currently working on customizing an accordion using jQuery for the animation effects. However, I am facing an issue where clicking on the accordion header causes the border around the plus sign to shrink in size as well. My goal is to only have th ...

The sorting of elements using the jQuery sort() function encounters issues on webkit browsers

Looking for a solution to sort elements by a number? Consider this part of a function that does just that. The number used for sorting is fetched from a data-ranking attribute of the element: $(".tab_entry").sort(function(a,b){ return parseFloat(a.dat ...

Dropping and dragging in the Dojo for the nested lists

Within my HTML code, I am using the Dojo drag and drop feature to sort attributes and move them to another section. However, I am having trouble figuring out how to sort the sections themselves. Here is the structure that I have created: <ul accept=" ...

Receive the height from the parent element using the box-sizing property set to border-box

Let's talk about a CSS challenge. .parent{box-sizing: border-box; height: 60px; border: 1px solid green;} The child div has its own styling: .child{height:inherit;background: red} Here is the code snippet: ...

What is the best way to reduce the spacing between subplots?

I am working on a subplot with multiple bar charts. Here is the code I have: fig = make_subplots(rows = 4, cols = 1) fig.append_trace(go.Scatter( x=[3, 4, 5], y=[1000, 1100, 1200], ), row=1, col=1) fig.append_trace(go.Scatter( x=[2, 3, 4], ...

Transfer the information of a selected element to a different element

Hello, I am trying to transfer content from a child element to another element. In my HTML setup, there is a hidden div named "DetailsExpanded" and multiple items called "IconWrapper". When an "IconWrapper" is clicked, I want to copy the content of its "I ...

Enable highlighting a table border when hovering over it

Is there a way to highlight the boundary of a table row when hovering over it? Something like this: I attempted to use CSS with the following code: .ant-table-tbody>tr.ant-table-row:hover>td, .ant-table-tbody>tr>td.ant-table-cell-row-hover{ ...

Is there a way to keep my footer fixed to the bottom of the page in Google Chrome?

I recently made some updates to my aging website by adding a footer menu. However, I encountered an issue with the placement of the footer on Google Chrome. It appears too high, overlapping certain elements of the site. I attempted to resolve this problem ...

take a paragraph element outside of a container div

In my ASP project, I have incorporated JavaScript and CSS code that I obtained from JonDesign's SmoothGallery demo website. Now, I am trying to move the p tag containing the summary out of the div. Here is the current code snippet: <div id="myGall ...

Refresh iOS / iPad website only upon scrolling, not when utilizing anchor links

Currently, I am in the process of troubleshooting this website: This site is hosted on a LAMP server and is utilizing CMSMS 2.1x, if that detail makes any difference. (By the way, the smarty components are causing some performance issues.) While the desk ...

What are the essential files needed in Kendo UI Core for a mobile app?

Several months ago, I created a trial Kendo mobile app but now I want to verify it using the most recent version of Kendo UI Core. In my previous project, I referenced the following files: <link href="../styles/kendo.common.min.css" rel="stylesheet" / ...

When using a custom selection color to highlight underlined text, the underline becomes invisible

I am currently working on a website where I want to customize the text selection color. ::selection { background-color:#00ffff; } However, there seems to be an issue in this specific situation: p::after { content:"Try selecting the above elemen ...

Exploring deep nested components and elements in Angular for a targeted specific functionality

Is it possible to apply the ng deep css class to only one specific checkbox in my component, rather than all checkboxes? I want to customize just one checkbox and leave the others unchanged. How can this be achieved? Thank you. I need the CSS modificatio ...