What causes an element with position:absolute to be placed behind the ::after pseudo-element?

Being a beginner in HTML and CSS, I recently encountered a challenge while working on some exercises. My goal was to create a website with a blur effect, so I decided to design a header with the class "showcase" and nested inside it, a div with the class "content".

<header class="showcase">
        <div class="content">
<img src="img/pexels-photo-373912.jpeg" alt="Photo">
<h2 class="title">Welcome </h2>
<p class="text">Lorem, ipsum dolor sit amet consectetur adipisicing elit. Neque, quidem!</p>
        </div>
    </header>

To achieve the desired background-image with a blur effect, I utilized the ::after pseudo-element in CSS:

.showcase::after{
    content:"";
    background-image: url(img/action-america-architecture-378570.jpg);
    background-size:cover;
background-position: center;
height: 100vh;
filter: blur(10px);
display: block;
transition: 1000ms;

}

However, an issue arose when I changed the position of the div with the class "content" to absolute:

.content{
    position: absolute;
}

Upon making this adjustment, I noticed that the div was positioned behind the ::after background-image. Since the default position for ::after or ::before is static, shouldn't it be the other way around with .content having position:absolute? Can anyone confirm my understanding?

Answer №1

Add the z-index property to the content class with a value greater than zero, as it defaults to zero.

.content{
position: absolute;
z-index:2;
}  

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

What is the proper way for a browser to handle a srcset attribute containing the same path twice?

When the same path or similar sized images with different pixel density descriptors are used, how does the specification address it? An interesting case study is observed when viewing an image in desktop browsers like Windows Firefox 82.0b2 and Chrome 85. ...

Eliminate HTML inserted into Selector

My approach to handling validator errors involves injecting HTML next to the incorrect content, which is then displayed correctly when clicked. However, I am facing challenges in removing the injected HTML once the bad data is corrected. Despite trying var ...

Is there a way to submit HTML form data using the action attribute without triggering a redirection to a different page?

I am currently working with Angular and Plaid. My goal is to submit a form that sends the public_token to /authenticate using the 'action' attribute in the HTML form. How can I achieve this without being redirected to another page? Step 2: Easy ...

The intricate scripting nestled within the jQuery function

When using jQuery, I am looking to include more codes within the .html() function. However, I also want to incorporate PHP codes, which can make the writing style quite complex and difficult to read. Is it possible to load an external PHP/HTML script? fu ...

Tips for incorporating the .click function with an overlay

Having some trouble using the .click function in conjunction with jQuery Tools overlay. HTML: <p id="click">Click here:</p> <div class="pop"> <div> <p>Insert text here</p> </div> </div> jQuery func ...

The command response.setHeader("Refresh", "0") failed to execute

My webpage needs to be refreshed when the user session has expired or the connection is not active. Despite trying various codes, I have been unsuccessful in achieving this. The last code snippet that I implemented is as follows: if(session.getAttribute(" ...

Mixing without Collections

After initially posting this question yesterday, I realized that I needed to clean up my code before proceeding. However, for my assignment, I am required to create a JavaScript quiz where the questions and answer choices are shuffled every time a user ret ...

Can we render layouts based on specific conditions?

Is there a way to dynamically change layouts in a component based on a condition? <template> <layoutA> //component contents </layoutA> </template> and switch to this layout: <template> <layoutB> //componen ...

Troubles with Flex wrap in CSS3 on iOS 10.3.2 browsers (Chrome and Safari)

Before sending me to other similar questions, keep in mind that I have already gone through them, attempted the solutions, and they are not resolving my issue. The problem I am encountering involves the flexbox layout. I am using the flexbox layout for ce ...

Is it possible to validate link clicks and integrate PHP within JavaScript functions?

Before anyone mentions security concerns, please refrain. Imagine I have an index.php. This page contains several links to 'home.php', each with different data stored in the href attributes. For example: Link 1: 'home.php?data=1&count ...

When scrolling, the fixed menu bar at the top of the page is making the content below jump

I am attempting to create a fixed submenu that sticks to the top of the page when scrolling, but I am encountering some issues. The current code I have is as follows: $(window).scroll(function () { if ($(window).scrollTop() > 175) { $('#loca ...

CSS can be utilized to craft intricate and dynamic shapes

Currently, I am attempting to produce a trapeze-like design utilizing various techniques in order to achieve the best possible outcome. The shape I am aiming to create is similar to this: (the content inside the shape will consist of images and text) Th ...

Adding a special ie7 glow effect to hyperlinks

Currently, I am facing an issue with a website that I am in the process of redesigning. The problem seems to be specific to Internet Explorer 7 (ie7). If you visit dev.indigoniche.com (you may be redirected back to the main site due to a cookie issue, in w ...

Displaying multiple image blobs within a div element

I've been able to successfully retrieve image blobs from a MySQL database using PHP code found here on Stack Overflow. Now, my query is how can I display multiple image blobs in different divs from the same database? Below is my current code. Any assi ...

Click on the header to activate the accordion link with a trigger

I am having an issue with a trigger. My goal is to make the accordions collapse not only by clicking on the link, but also by clicking on the entire header panel. Below is my header's code: <div class="accordion-head" role="tab"> <div cl ...

Trouble with importing scss file in sass and bootstrap collaboration

I am using Sass with Bootstrap 4, and now I'm facing an issue in my Sass folder where I have an app.scss file that includes: @import _customVariables.scss @import node_modules/bootstrap/scss/functions @import node_modules/bootstrap/scss/mixins Howev ...

TS2339 Error: The property 'Default' is not a valid property for type 'string'

Hello, I am a beginner with Angular 2. I have encountered some issues that I need help with: Error Messages: app/components/playing-cables/-update.ts(82,12): error TS2339: Property 'options' does not exist on type 'jQuery'. app/compone ...

What sets apart the use of multiple forms versus multiple submit buttons?

What are the advantages and disadvantages of using multiple forms on a single web page compared to using one form with multiple submit buttons? Is there any noticeable difference? ...

Modify how various classes are shown when hovering over a pseudo class

This is my customized scss code .image-container { position: relative; .delete-image { display: none; position: absolute; top: 0px; right: 0px; } .make-primary { display: none; position: absolute; ...

Tips for disregarding line breaks in BeautifulSoup parser when using python

Here is my first question. I am currently utilizing BeautifulSoup to extract content from a website. The specific content I am targeting is located within a td tag, which can sometimes span two lines with a line break in the code. For example, when lookin ...