I encountered difficulty implementing the "flex justify content space between" on my Odoo website due to a concealed ::after element causing interference

When using "flex justify content space between" to arrange elements, I noticed that having an ::after element inside the div adds an unwanted margin on the right side. Is there a way to remove this?

Here is a simplified version of the HTML:

<div>
    <div></div>
    <div></div>
    <div></div>
    ::after
</div>

And here is a simplified SCSS code snippet:

div {
   display: flex;
   justify-content:  space-between;
   div {
   margin: auto;
   }
}

Check out the image to see the issue – without the ::after element, the purple part on the right would not be there.

Answer №1

What is the function of the ":after" pseudo-element? If you want to prevent it from affecting the layout, consider applying "position: absolute;".

Alternatively, you could introduce an additional wrapper element like this:

.container {
  display: flex;
}

.inner-container {
  display: flex;
  justify-content: space-between;
  flex-grow: 1;
}

.container:after {
  content: "after";
  background: red;
}
<div class="container">
  <div class="inner-container">
      <div>1</div>
      <div>2</div>
      <div>3</div>
  </div>
</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

Transform the input value into a string

Struggling with converting an input value into a string. HTML: <input type="text" placeholder="Email Ex: john123" id="emailinput"> <input type="text" placeholder="Domain Ex: @gmail.com" id="domaininput"> JS: let emailVal = document.getElem ...

CSS - Implementing two stylesheets sequentially in an Opencart website

Currently, I am encountering a frustrating issue on my website. The CSS files are loading in a peculiar order - first the default styles, followed by my custom overrides in luke.css. This results in a brief display of cream color on the left sidebar before ...

Tips for placing a searchbox on top of a carousel?

I need to create a search box that overlays on top of a carousel image. I currently have the search box positioned absolutely, but it's not responsive as it doesn't stay within the carousel as the width decreases. How can I make it responsive whi ...

Is it possible to apply multiple objects to a single element using ng-style?

Within our controller, we are defining two ng-style objects. $scope.rightpadding = { paddingRight : '11px' } $scope.toppadding = { paddingTop : '7px' } Our goal is to combine both of these in an ng-style directive, like so ...

What is the best method for displaying an external SVG file using the <use> tag in HTML?

I seem to be struggling with a task that I thought was quite simple. Despite trying to replicate 8 other examples I found online, such as this one, I just can't seem to make it work. For the sake of simplicity, let's focus on this scenario: I ha ...

Conceal the column title for order items in the WooCommerce admin panel

I've been attempting to hide certain columns within the administrative section of Woocommerce, but have had no success with the code I'm using. I'm currently stuck and my question is: Is there a way for me to conceal specific column names i ...

`the challenges encountered in a Web Site project (not a Web Application)`

I am currently working on a Web Site project, not a Web Application, and I have encountered two problems due to this distinction. One issue stems from the fact that I have a custom control derived from BaseValidator which had to be placed in the App_Co ...

How to display only the thumbnail on WordPress archive page and remove the post excerpt

I am currently in the process of revamping my category archive to resemble a grid layout by utilizing custom CSS. I have successfully eliminated the elements I desired using code like this: .archive .entry-footer { display: none; } Now, I only have t ...

CSS for the root folder of an ASP.NET website

After deciding to venture into ASP.NET, I quickly encountered my first obstacle. The folder structure is as follows: \ ->Admin -->Admin.Aspx ->CSS -->Style.css ->Images -->bg.gif Default.aspx Default.master Both admin.aspx and ...

When the first Div is clicked, can it move to the end of the list?

I have designed a collapsible tab and I would like to make some modifications. I want it so that when the user clicks on the first tab, it will move to the last position in the collapsible list, and the same should happen for the other tabs as well. For ex ...

Struggling with a background problem that arises specifically when using transform: rotateY() - interestingly, it appears to be isolated to

Attempting to create a 3D Flip Card in CodePen has presented an issue. When hovering over the card, the content is intended to rotate along the Y axis. However, upon implementation in CodePen, the background of the card front becomes transparent, revealing ...

Is there a way to align images with text in an Outlook email template since vertical-align is not functioning properly? Are there any alternative methods

Hey there, I'm currently working on a Mail template and running into alignment issues with icons in certain versions of Outlook. It seems to be related to the Word rendering engine. Are there any alternative solutions available to ensure proper alignm ...

Transforming a string into the date input type layout

I am working with an HTML input type of "datetime-local" that I save in a Datetime field within a MS SQL Server database. Upon loading the edit page, I aim to populate this HTML date field with the value retrieved from the database. Upon examining the va ...

Tips for displaying columns from two tables that have a "one to many" relationship in an HTML table?

I am working with a database that consists of two tables, each having a "one to many" relationship. The first table is named 'data' with columns for name, phone, and personid. The second table is named 'links' with columns for linkid, l ...

Guidelines for refreshing owl carousel on ng-click using AngularJS

I am encountering a significant issue with the use of an owl carousel in angular.js. It functions properly the first time, but when I have buttons on the same page and need to rebuild the owl carousel upon clicking a particular button with new data, that&a ...

What is the best way to use toggleClass on a specific element that has been extended

I have been experimenting with this code snippet for a while. The idea is that when I hover my mouse over the black box, a red box should appear. However, it doesn't seem to be working as expected. Could someone please review this script and let me k ...

Tips for shortening block text on your website with a link at the end

I'm currently working on implementing a truncating block of text with ellipses that can expand and collapse using a button in a React project. Individually, I've been able to truncate the text correctly with ellipses, and my coworker has position ...

Pass the callback function `cb_func` as a parameter to the `foobar` function when calling it in the `onclick`

I have an element that I want to trigger an onclick event with a callback function. Here is the code snippet: function cb_func() { alert("hello world!"); } function foobar(i, cb) { // do something if (cb != undefined) cb(); } onclic ...

Aligning Cards using Bulma Styles

Currently in the process of developing a Pomodoro Timer application and utilizing Bulma as my CSS Framework. I am really enjoying working with it thus far, although still getting the hang of Flexbox. I am seeking advice on the best approach for this projec ...

Cloning blank records in SQL during data refreshment

My recent project involves a system where users can input data that gets stored in a MySql database via SQL queries. However, I'm encountering an issue where empty data is inserted into the database every time the page is refreshed. The connection, qu ...