Steps for adding a cover over an image (not utilizing clip-path, but the reverse approach)

I am currently exploring how to create a div with a mask that allows me to see through it to reveal a background image. Most tutorials I find discuss clip-paths, but what I am seeking is the opposite of this concept. Clip-paths typically display what is inside the clip, whereas I want to implement a mask that showcases the external area of the clip instead.

If you'd like to visualize the effect I aim to achieve, take a look at this example. Below, I provide a detailed explanation of this sample illustration.

The scenario involves a div featuring a background image. Nested within this div is another element that spans the entire width and height of its parent container (which includes the background image) and boasts a semi-transparent background color in rgba format. My objective is to apply a mask to this overlay div (the one with the rgba background color) so that a circular shape is removed from the center, revealing the complete background image without the color overlay interfering.

To dive deeper into this topic, check out this jsfiddle link that demonstrates the setup I described, albeit without the mask component as my knowledge on implementing it remains limited.

<div class="backgroundImage">
  <div class="backgroundOverlayWithMask">
    <!-- content will be here -->
  </div>
</div>

.backgroundImage {
  width: 100%;
  height: 500px;
  background: url(https://upload.wikimedia.org/wikipedia/commons/4/47/New_york_times_square-terabass.jpg) no-repeat center center;
  background-size: cover
}

.backgroundOverlayWithMask {
  width: 100%;
  height: 500px;
  background-color: rgba(0, 0, 0, 0.75);
}

Answer №1

Incorporating a solution utilizing the properties box shadow, :after, and flex. Check out the demonstration on this Fiddle, inspired by web-tiki's response found here.

#inner {
  position: relative;
  width: 100%;
   ...
</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

Tips for accessing webpage data using pandas

My attempt to extract data from a table on the webpage is proving challenging. The code I am using is as follows: import pandas as pd url="https://datahub.io/sports-data/german-bundesliga" pd.read_html(url)[2] Despite this, the code successfu ...

To achieve the desired format, where should I press or manipulate the information?

I need help with manipulating arrays to generate a specific JSON file structure. I've made some progress but got stuck at this point: var T_nn_IN = document.getElementById('datatablenewname'); var tabledata_newname_initialname = []; ...

When the submit form is clicked, the confirmation dialog box instantly redirects to a different page without waiting for the user to confirm

<!DOCTYPE html> <html> <head> <style> .enter-userdetails{ width:500px; margin: auto; background-color: #eee; text-align: center; padding: 20px; } ...

Finding the text content of a div element using react testing library

<a className="stats__back" href="./.."> &#129044; </a> <div className="profile-heading">ACCOUNT</div> <div className="profile-header" ...

Positioning two social media share plugins (Facebook and Twitter) side by side on a single line (vertically aligning them

Having implemented Twitter and Facebook share plugins on my site, showcased in this example, I'm facing the challenge of aligning the buttons vertically. Despite attempting to adjust margin-top and padding-top attributes, the alignment issue persists. ...

Tips for incorporating jQuery UI into Angular 6

No matter how many methods I have tried from StackOverflow, I cannot seem to get jquery-ui to work in my angular 6 component. Here's what I've attempted: I went ahead and ran npm install jquery jquery-ui to install both jquery and jquery-ui. ...

The argument type of '() => JQuery' cannot be assigned to a parameter type of '() => boolean'

Having trouble writing a jasmine test case for my method due to an error: spec.ts(163,18): error TS2345: Argument of type '() => JQuery' is not assignable to parameter of type '() => boolean' Any suggestions on how to resolve ...

Troubleshooting HTTP Issues in Angular 2

I am currently facing an issue with my Angular 2 project's Http functionality. I have defined it as a parameter in the constructor, but it keeps printing as undefined. Below is the snippet of code from my project: import 'rxjs/add/operator/toPro ...

The names in the lists appear with a visible scrollbar, making them easily

I'm having some issues with this dropdown menu. http://jsfiddle.net/vnr0rbuu/2/ The problem arises when using a different mouse or a PC, as the scrollbar appears and my list items don't apply the inline-block style correctly. Any suggestions on ...

When it comes to using the text() function, the statement encounters difficulty

let person = $(".tekst").text(); if (person=="XxX") { $("#discu").css("display", "none"); } alert(person); When I access my element with class .tekst and get its text using the text() function, it correctly displays as XxX, which is what I expected. ...

What is preventing me from inserting space before the buttons in PHP?

I'm having trouble creating additional space after the drop-down menu. The spacing is not showing up... PHP <?php $connect = mysql_connect("server","username","") or die("Error connecting to MYSQL"); mysql_select_db("database") or die("Error conn ...

Issue with Bootstrap 5: Navigation feature struggling in carousel

I am currently using bootstrap 5 and looking to incorporate an image carousel and a modal into my project. Here is the sample code I have: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cf ...

When attempting to browse for image files, Postman fails to display images

While trying to upload image files through Postman, I encountered an issue where the browser did not display any image files. It's important to note that I am using Ubuntu as my operating system. https://i.sstatic.net/1D3ro.png When I clicked on "se ...

Is it possible to automatically resize my text below an image using only HTML and CSS?

I need my text wrapper width to automatically shrink below an image. For instance: <figure> <img src="mypicture.jpg" /> <figcaption> This is a lengthy description. This is a lengthy description. This is a lengthy descrip ...

Changing the color of text in one div by hovering over a child div will not affect the

When hovering over the child div with class .box-container, the color of another child div with class .carousel-buttons does not change. .carousel-slide { position: relative; width: inherit; .carousel-buttons { position: absolute; z-index: ...

Using Rails to display a set of partials generated by a presenter function

Currently engrossed in watching Railscast on presenters, I find myself eager to refactor one of my presenters to incorporate the page template. The specific screencast that caught my attention is 287-presenters-from-scratch Following the suggested method ...

HTML and CSS for an off-canvas menu

Looking to create an off-canvas menu that smoothly pushes content out of view instead of cropping it. Additionally, I want to implement a feature that allows the menu to close when clicking outside of it. I found the code for the off-canvas menu on W3Scho ...

Looking for some CSS to style the image below

Looking for CSS assistance to style the sample image provided below. The letter within the circular element is contained in a div while the subscript Z is represented by an image of a circle. https://i.sstatic.net/sKF1H.png .text-center { text-align: ...

How do prototype, the $.extend method, and the concept of "return this" all connect with each other?

I've been assigned a legacy project, and I find myself puzzled by the purpose of this code. define(['jquery', 'components/BaseComponent', 'bootstrap'], function( $, BaseComponent, bootstrap ) { 'use strict&a ...

Is the accept attribute of the input not recognizing application/json as a valid input type?

My application allows users to upload files, including JSON files. While most browsers recognize file extensions specified in the accept attribute of the input element, Safari may not always behave as expected. In cases where MIME types need to be used, sp ...