Creating a photo with a sharp-edged background blur: techniques and tips

I've been experimenting with achieving a blurry background image for a div container but have encountered an issue. When applying the blur filter, it also blurs the edges, causing the blurred image to overflow its frame. Here's what I have attempted so far:

.one {
  height: 400px;
  width: 400px;
  border: 1px solid black;
}

.a {
  background-image: url("https://i.imgur.com/JCyxUxA.jpg");
}

.b {
  background-image: url("https://i.imgur.com/O1jVhYH.jpg");
}

.thing {
  object-fit: contain;
  width: 100%;
  height: 100%;
}

.bl {
  filter: blur(20px);
}
<div class="one t">
  <img class="thing" src="https://i.imgur.com/JCyxUxA.jpg" alt="">
</div>  
<div class="one t">
  <img class="thing bl" src="https://i.imgur.com/JCyxUxA.jpg" alt="">
</div>  
<!-- <div class="one a">
</div>
<div class="one b">
</div>
 -->

Answer №1

One solution to consider is incorporating the CSS property overflow:hidden; into the container (identified by class one in this scenario). By doing so, any excess content on the child elements will be hidden if it extends beyond the boundaries of its container.

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

javascript creating php doesn't function

Greetings! I have an option list in HTML that is being dynamically generated by PHP. My goal is to retrieve the value selected from the option list without having to submit the entire form, and then trigger another PHP function to populate another set of o ...

"Exploring the Functionality of Page Scrolling with

Utilizing Codeigniter / PHP along with this Bootstrap template. The template comes with a feature that allows for page scrolling on the homepage. I have a header.php template set up to display the main navigation across all pages. This is the code for th ...

What is the best method for adding a line break in the body of an email when we include the recipient, subject, and message?

Do you have a requirement where information needs to be sent to an end user via Gmail (preferred) and they need to click on a button in the email body to respond? The button response is set up with predefined to, subject, and body fields, but there are dif ...

Troubleshooting issue: PHP script displaying an HTML table containing PHP code results in a syntax

I have a piece of code that I want to use to output an HTML table with PHP embedded in it. EDIT: Apologies, I realized that I didn't provide the entire code. Maybe this will make a difference. <!doctype html> <html> <head> & ...

Is an extra outer div required for Bootstrap 5 dropdowns?

After encountering a persistent issue with Bootstrap 5 dropdowns being clipped by the table or table-responsive div, despite the data-boundary="viewport" attribute not working as expected, I found a solution. Simply adding the position-static class resolve ...

Show JSON information in a JSP page and an HTML file simultaneously

As a Java newbie, I am facing an issue with my test.json file which is in an array format like this: { "Result": "OK", "TotalRecordCount": 23, "Records": [{ "vEmail": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data- ...

Gradually eliminate the background color in one smooth motion

When new messages appear, I want them to be subtly highlighted as users hover over them. The background color will slowly disappear on hover thanks to the CSS code provided below. However, this effect should only happen once, which is why I need to remov ...

Creating validation rules for a form that includes a From Date and a To Date

Looking to implement validation for the from date and to date fields within a template-driven form. Is there a way to ensure that the "from date" is always greater than the "to date," and vice versa? Additionally, I would like to find a way to reuse this ...

Identifying all unused CSS class selectors in the code that do not have any CSS rulesets assigned

Is there a way to retrieve a list of all the CSS classes I have used in my code that do not have a corresponding "CSS ruleset" defined for them? For example: /*Definition (or Rule set) for .some-random-class doesn't exist or is ...

Operating a slider on a web page built with HTML

I am currently working on developing a loan calculator that involves two range sliders interacting with each other to display monthly payments in a label. Here are the specific requirements: Display only 5 values on the "Month" range slider: 12,18,24,30,3 ...

Enable the entire button to be clickable without the need for JavaScript by utilizing a Bootstrap 5 button

Is there a way to make a button redirect when clicking anywhere on it, not just the text inside? Here is the button code utilizing Bootstrap 5: <button class="btn btn-rounded btn-primary" type="button">Placeholder Text</button& ...

Animate elements in Vue.js when navigating between pages is a great way to enhance user

I'm looking to add animation to a specific element once the route page finishes loading. This is not related to route page transitions. I've experimented with various methods, trying to animate a progress bar based on dynamic data values. I attem ...

Unsuccessful CORS on whateverorigin.org with YQL

Despite trying all three methods, I keep getting an error regarding cross domain access denied. Previously, I had successfully used YQL in different parts of my applications, but now it seems to have stopped working as well. JSFIDDLE <script> $(fun ...

Show a picture without specifying its file location

Looking for Suggestions on a New Title I am interested in using a script as the source attribute for an image, like this : <img src="img.js"/> Note: I am open to using any programming language, whether it be javascript or php. Here is what my fol ...

Customizing Bootstrap CSS styles using CSS: A step-by-step guide

I am encountering an issue with the navbar in my Bootstrap project. Despite having specified the background color to be aqua in my boot.css file, it is not overriding the default dark color set in the Bootstrap CSS. To customize the styling of the navbar ...

Utilizing the checked or clicked property of radio buttons for my specific scenario

Hello everyone, I am currently working on Rails 3.2.13 and have implemented the following script in my view file. Whenever a user selects 'Other' as their owner type, I need the div with id=group_user_id to open and save the operation at the end. ...

showcasing JSON data in an HTML table with pure JavaScript

I am currently utilizing vanilla JS to send a client request to a REST web service that I have designed. The GET method I have implemented returns a list of books (List) in JSON format: 0: {name: "To Pimp a Butterfly", isbn: "ACBCDDSA", availableCopies: 1 ...

The button is unresponsive to the cssStyleDeclaration within the DOM

I've been grappling with a seemingly simple bug for over an hour and could really use a fresh perspective to help me identify the issue. In the code snippet below, I am attempting to change the style of two buttons. One button (deleteBtnToDecorate) r ...

Imagine a scenario where clicking on an image causes it to be rotated or

Could use some assistance figuring out what's missing here. I've added a random photo from Wiki, similar in size to the images I'll be working with. The images will vary in size, but I want them to always remain visible within the browser w ...

Is it possible for PHP to not provide an image to HTML?

I'm currently facing an issue trying to display an image in HTML using a PHP script. Despite my best efforts, it's not functioning as expected :-( Here is the code snippet from my image.php script: <? $_GET['f'] = 'all_thre ...