Error: Psuedo After element fails to display

I've been struggling to get a small chevron to display as a pseudo-after element, but for some reason it's just not showing up. I've tried adjusting the z-index without any luck. Any suggestions on what I might be doing wrong? Here's how I envision it looking:

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

          <div class="post-arrow post-arrow--left"></div>
         
          <div class="post-arrow post-arrow--right"></div>

.post-arrow {
    position: relative;
    height: 80px;
    width: 80px;
    z-index: 0;
    border-radius: 50%;
    background-color: rgba($color-black, .9);

    &--right {
        &::after {
            position: absolute;
            display: block;
            z-index: 1;
            background-image: url('../../../lib/images/chevron-right.png');
            background-repeat: no-repeat;
            content: "";
            color: $color-white;
            height: 80px;
            width: 80px;
           
        }
    }
        &--left {
            &::after {
                position: absolute;
                display: block;
                z-index: 1;
                background-image: url('../../../lib/images/chevron-left.png');
                background-repeat: no-repeat;
                content: "";
                color: $color-white;
                height: 80px;
                width: 80px;
               
            }
    }
}

Answer №1

Your basic CSS structure seems solid to me. I simplified your code by removing any dynamic color elements or local image references, and it appears to be functioning correctly. Double-check your image paths or any other potential issues.

.post-container {
  position: relative;
  height: 100px;
  width: 100px;
  border-radius: 50%;
  background-color: blue;
  display: block;
}

.post-right-arrow::after {
  position: absolute;
  display: block;
  background-image: url('https://www.example.com/image.jpg');
  background-repeat: no-repeat;
  content: "";
  color: #fff;
  height: 100px;
  width: 100px;
}
<div class="post-container post-right-arrow"></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

What is the method for changing the color of text within a button when hovering using CSS?

In my OceanWP WordPress theme, I customized the top-bar menu by adding a button labeled "Post a Job" using CSS. Screenshot Link I have two top-bar menus - one for logged-in users and another for logged-out users. The "post a job" button has a 2px purple ...

To collapse a div in an HTML Angular environment, the button must be clicked twice

A series of divs in my code are currently grouped together with expand and collapse functionality. It works well, except for the fact that I have to click a button twice in order to open another div. Initially, the first click only collapses the first div. ...

Make sure to include !important for the hidden property when applying inline styles in React jsx

Is there a way to include !important in the hidden property within React JSX inline style? I'm attempting to conceal the scroll bar in an Ag Grid table component as it is displayed by default. I've already attempted: ref={(nod ...

What is the deal with CSS relative magnification?

I am currently utilizing a PHP styleswitcher along with alternate stylesheets in an attempt to replicate the functionality of browser zoom (done using keyboard shortcuts cmd-plus or ctrl-plus). At the moment, when clicking on the "zoom in" graphic, it is ...

How come my div won't align next to the image? It keeps appearing behind the image instead

I need help figuring out why I am unable to float a div box next to an image. Despite successful attempts with text, the div seems to be getting stuck behind the image instead of appearing beside it. http://jsfiddle.net/n8ZDQ/1/ (observe how the red div i ...

The ReactBootstrap flexbox feature does not automatically adjust its height to match the content within

My struggle is with getting the height of this flexbox column to match that of its content. When the window width is less than 576 pixels, only one column is displayed per row. However, in this scenario, one of the columns (the teal one) ends up being too ...

Modify the font of all text in a specific column using iTextSharp

For my PDF project, I am taking a string of HTML and using HTMLWorker.ParseToList to add each element to a column. Despite numerous attempts, I have been unable to change the font. I tried adding the font to each element as I add it: el.Font = times; But ...

@media doesn't seem to be functioning properly when the screen width is below

I've been working on making my website fully responsive, but I've run into an issue where it won't recognize anything below 980px in width. Here is the CSS code I'm using: @media screen and (max-width:1029px){ h1{ font-size ...

Get a calendar that displays only the month and year

I am looking to incorporate two unique PrimeFaces calendars on a single page. The first calendar will display the date, while the second one will only show the month and year. To achieve this, I have implemented the following JavaScript and CSS specifica ...

Utilizing a lone div for clearing a float

For a long time, my go-to method for clearing floats has been using <div style="clear:both;"></div>. However, I recently began wondering if in HTML as XML, could I simply use <div style="clear:both;" /> since they essentially serve the sa ...

Bootstrap seems to be struggling with recognizing the last child of a button group. What steps can I take to troubleshoot and resolve this

I'm facing a small but annoying issue with my button group. The last button in the group appears rectangular instead of having rounded corners at the top right and bottom right. This is because the a.btn element is followed by a modal within the btn-g ...

exploring the contrast of css versus javascript selectors

Could you please explain the contrast between div#name and #name? Is there a significant difference when using class or id to position an element? Thank you for your help. ...

Make changes to a characteristic of the pseudo-class ":host"

Within an Angular project, I am attempting to modify the border-top attribute of the pseudo-class :host associated with the component called p-table-row. This specific component is part of a library created by Porsche and can't be directly edited. Vie ...

What is the best way to obtain SAPUI5 Explored designs?

I am working on implementing a sap.ui.Table in my project, similar to the one showcased in the SAPUI5 Explored app. The table I am trying to create should allow for multi-selection of items using checkboxes on the left side. However, after downloading th ...

Keep the image proportion (square) the same while allowing the container height to automatically adjust

Encountering an issue while attempting to maintain image aspect ratio In a container with height: auto; max-width: 640px, I aim to showcase four 1:1 aspect ratio images per row The dilemma arises when the window's/container's width falls below ...

The submenu is not aligned directly under its parent item

The sub-menu is not appearing below the parent item as expected. I have tried removing and adding the 'absolute' property, but it doesn't seem to have any effect. Check out the JS Fiddle for reference: http://jsfiddle.net/42qg5/ HTML Code ...

Styling Input elements with a unified border in Bootstrap

[Issue Resolved] I have been working on setting a single border between multiple inputs inside a form-group in Bootstrap. Currently, the border is only visible when the input is not focused and it is the last one. However, my expectation is for the bo ...

Is it possible to upload multiple files using JavaScript?

My JavaScript project can be found on GitHub. You can check out a live demo of the project here. The main goal for my HTML Button with id='Multiple-Files' is to enable users to upload multiple files, have them displayed in the console, and then ...

Employ ng-class function in Angular JS

Utilizing the ng-class feature to include CSS classes has been a bit challenging for me. Despite reading numerous articles on the topic, I am still struggling with implementing a function call within ng-class. Below is the expression I am working with: n ...

Creating uniform line lengths with a ruler utilizing Fabric.js

I have a div that scrolls horizontally and contains a ruler div and a canvas where I draw horizontal lines of varying lengths. When drawing the lines, I want to ensure they are accurately measured against the ruler using JavaScript and CSS: var canvas = ...