Pseudo elements disappear when utilizing Flexbox

I am looking to create two divs that each take up 100% width, but I am open to other configurations. Additionally, the active tab should have an arrow displaying below it.

Despite using flex-grow in my flexbox setup, the placement of the after pseudo-element arrow does not seem to be affected. When in full screen mode, the arrow is visible, but once flex-grow comes into play, the arrow remains stationary and gets hidden behind the background color.

https://codepen.io/sherrylking/pen/MWWXEBv

.qo-tab-section {
    display: flex;
}

.qo-tab-section div {
    padding: 20px 20px 20px 20px;
    flex-basis: 50%;
}

.qo-active-tab:after {
    content:'';
    position: relative;
    border-style: solid;
    border-width: 20px 20px 0;
    border-color: #027777 transparent;
    display: block;
    width: 0;
    z-index: 1;
    top: 43px;
}

https://i.sstatic.net/FzjV3.png

Answer №1

The issue lies in the utilization of top: 43px. This fixed position is causing the arrow to remain static relative to the flex item, resulting in misalignment upon resizing.

To resolve this, adjust the positioning by using absolute positioning for the arrow and relative positioning for the containing block.

Please include the following code snippet:

.qo-tab-section div {
    padding: 20px 20px 20px 20px;
    flex-basis: 50%;

    /* New */
    position: relative;
}

.qo-active-tab:after {
    content:'';
    border-style: solid;
    border-width: 20px 20px 0;
    border-color: #027777 transparent;
    width: 0;
    z-index: 1;

    /* Top position no longer necessary */
    position: absolute;
    top: 100%;
    left: 0;
}

Check out the jsFiddle demo for a visualization

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 to detect a specific animation completion on an element?

How can I ensure that a specific animation ends when multiple animations are triggered on an element? My scenario involves an overlay song list that appears when a list icon is clicked. The challenge lies in closing the menu smoothly. I have implemented a ...

Unable to utilize Bootstrap inside the Shadow DOM of Custom Elements

I am currently in the process of developing a web component using plain JavaScript and implementing Bootstrap 5 for styling purposes. While the Bootstrap styling is functioning correctly, I am encountering issues with the event listeners for the Bootstrap ...

Text: The character code "f068" is displayed as "?"

I need to retrieve the content value from my pseudo element. script = "return window.getComputedStyle(document.querySelector('small.fa.text-muted.fa-minus'),':before').getPropertyValue('content');"; js = (JavascriptExecutor) ...

Adjust the size of the image to perfectly fit within the div without enlarging it

I have a variety of images with different dimensions, ranging from 50x100 to 4000x4000 pixels. My objective is to display these images in their original size or scale them down to fit within the browser window. However, I have encountered an issue where t ...

Closing Note in Drupal

Is there a way to adjust the footer message in Drupal without logging into the dashboard? I've checked all the files in cPanel, but I can't seem to locate the actual HTML for the website. I am only able to customize the body content, not the fo ...

How to center an item in a Bootstrap navbar without affecting the alignment of other right-aligned items

Currently, I am in the process of designing a website and have implemented a Bootstrap navbar. The navbar consists of three icons aligned to the right, and I am looking to center another element. However, when I use mx-auto, the element does not center per ...

The background image on my webpage does not adjust properly when I resize my browser window

After following a YouTube tutorial on building a website with Bootstrap, I encountered an issue when setting the background image to be responsive. The background didn't adjust as expected based on the video. Below is my HTML code: <!DOCTYPE html ...

Tips for concealing the navigation bar during page printing in Bootstrap 5

When attempting to print the page body, I am encountering an issue where the vertical "navbar" continues to display and covers a portion of the content. Below is the code I am using to hide the navbar when printing: @media print and (min-width: 800px){ ...

``Look at that cool feature - a stationary header and footer that stay in place

I'm seeking advice on how to design a website with a fixed header and footer that remain consistent across all pages, with only the content area altering. I've come across a site as an example - , but couldn't figure out how it was done even ...

Focusing on a particular iframe

I am currently using the "Music" theme from Organic Theme on my WordPress site and have inserted this code to prevent SoundCloud and MixCloud oEmbeds from stretching the page width: iframe, embed { height: 100%; width: 100%; } Although the fitvid ...

Bootstrap 4 collapse is experiencing some issues as it is not collapsing smoothly. It seems to pause halfway before

Why is this collapse stopping in half before collapsing completely? I have 5 divs collapsing at once, could that be the issue? The example on W3 schools works fine... Should I consider changing the collapse to a panel instead? Visit W3 Schools for more i ...

What happens when the overflow-hidden property is overlooked due to a child element being assigned absolute positioning?

When does overflow hidden not work as expected? If a child element overflows and has absolute positioning If the parent with overflow hidden is statically positioned When a second parent wrapper with relative positioning is added Why does this happen eve ...

Tips for modifying the default settings of a CSS framework like Material UI

Exploring the realm of CSS for the first time and feeling a bit lost. I am working with material ui alongside react and redux. My goal is to customize certain properties of a specific component, such as TextField with the disabled attribute. Upon inspectin ...

How to eliminate the arrow symbols in a scrollbar using CSS

Typically, a vertical scroll bar will display up and down arrows at both ends. However, is there a way to customize the appearance so that only the scroll bar itself is visible without the arrows? Below is the CSS code I am using: .scrollbar-vertical { ...

The CSS :lang() selector targets elements within documents that do not specify a particular language

Can elements that do not have a language set or inherited, meaning they are in an unspecified ("unknown") language, be targeted? Facts The language of an HTML document or element can be specified using the HTML lang attribute, for example: <html lang=& ...

Adjust the span's width to make it shift position

Currently, I am in the process of learning HTML and there is a specific question that has come up for me. Within my <div class="input-group">, there are three elements: one span, one input field, and another span: <span class="input-group-addon q ...

Uniform line spacing

Is it possible to ensure consistent line-height between all lines by specifying it as 0.99em for both P tags and UL tags? Along with that, is it possible to maintain a space of 0.99em between P tags and UL tags, as well as between P tags themselves? To se ...

Encountering a reference error during the gatsby build process

My project was functioning well as usual until I attempted to run 'gatsby build' and encountered the following error message: ReferenceError: Cannot access '_404' before initialization as well as ReferenceError: Cannot access '_ ...

CSS ratings bar styling

Looking to create a unique ratings bar for my website, I have some questions that need answering. Take a look at the codepen link to see what I've come up with so far. My main query is about incorporating two different colors for Likes (green) and Di ...

Use the CSS property of display:none; on elements that have not been selected

There are multiple divisions on this page, and one of them has the class "active". I am looking to hide all the divisions except for the one with the "active" class. Can you provide me with the appropriate CSS selector for achieving this? ...