Having trouble with the last child not appearing after in Chrome? Is there a problem with the pseudo-element usage?

Encountering a peculiar issue specific to Chrome (no problems in FF and Safari, not concerned about IE) that raises questions regarding whether it's a bug, incorrect usage of pseudo elements, or the compatibility of combining pseudo classes and pseudo elements.

The problem arises when Chrome appears to detect content="-"; in the last-child:after rule but fails to display it. Strangely, manipulating certain properties in the developer tools (like toggling the margin on and off) causes the content to suddenly appear.

Below is the simplified code snippet:

HTML:

<ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
</ul>

<div id="footer">
    <p>This is a footer</p>
</div>

CSS:

ul { text-align: center; }

#footer { text-align: center; margin-top: 200px;}

li:first-child:before, li:last-child:after, #footer:before {
    display: block;
    content: "-";
    color: red;
    margin: 10px 0;
}

Also available here: http://jsfiddle.net/D4T6L/4/

Whether declared separately or combined as shown does not seem to affect the outcome.

Could someone provide insight into what might be going wrong?

Answer №1

It appears to be a bug specific to Chrome. The following code snippet resolves the issue:

<ul>
  <li>One</li>
  <li>Two</li>
  <li id="blah">Three</li>
</ul>
<div id="footer">
  <p>This is a footer</p>
</div>

CSS rule targeting the last element using its ID:

ul { text-align: center; }   

#footer { text-align: center; margin-top: 200px;}

li:first-child:before, li:last-child:after, #footer:before {
   display: block;
   content: "-";
   color: red;
   margin: 10px 0;
}

#blah { }

If you eliminate "#blah{}", the issue will reappear.

UPDATE: This problem was resolved in Chrome quite some time ago.

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 best way to incorporate a Django variable as the width parameter in a style tag within HTML?

I'm attempting to utilize a Django variable as the percentage width value within a style tag in HTML, but it's not functioning correctly. Strangely, I've discovered that using curly braces {} within style tags is prohibited—this contradict ...

When Bootstrap 4 teams up with Autoprefixer, it results in malfunctioning old iPads

.row { display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-wrap: wrap; flex-wrap: wrap; margin-right: -15px; margin-left: -15px; } Recently, we implemented Bootstrap 4 and the Flex model at my company. We'v ...

What is the best way to create an image in the shape of a perfect circle?

Incorporating the Bootstrap V5.0 framework into my project, I set out to create a div containing a circular image along with some text content. While I was able to use a 50% radius to achieve a circular shape, I encountered an issue where the height of t ...

obtaining the values from a dynamically generated group of checkboxes

My dynamic checkboxes are categories that can be selected individually. <input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700">first</input> <input type="checkbox" name="SubCats" class="subcat-checkbox" value="180018 ...

Tips for incorporating images into AngularJS applications

Just starting out with angular js. I've run into an issue. I'm working with a json for my data and I'm unsure about how to incorporate images into my code <div ng-controller="myCtrl" class="container"> <div class="col-md-8"&g ...

Changing the width of an HTML table does not produce any noticeable results

I attempted to create a striped table with 5 columns. The desired column sizes are: 10% width --- 10% width --- 40% width --- 20% width --- 20% width However, my current code is not achieving the correct widths (the 'description' column does n ...

The element 'mat-slide-toggle' is unrecognized following the import

I'm currently facing an issue with using <mat-slide-toggle>Click me!</mat-slide-toggle> in a component that already has the MatSlideToggleModule imported. Strangely, I'm still encountering an error stating that it's not a recogni ...

"Enhance your website with Ajax code that enables automatic refreshing of a PHP file, keeping its values up-to-date

Before diving in, I want to make it clear that my understanding of ajax is limited. I'm currently working on a small application where I have a load.php file that echoes 3 variables: $loadout[0]; $loadout[1]; $loadout[2]; The PHP file is functioning p ...

Create a personalized message in PHP that corresponds to the specific row number

I created a table to show data sourced from a database. I decided to add a column that will display a message based on the row number being displayed. <form name="afisare1" method="POST" > <input type="submit" name="opt1" value="OK"/> ...

The grid elements are not in perfect alignment

I'm having trouble aligning the <p> element to the left and the image to the right. The image is not aligning properly with the fourth column, so I need to figure out how to fix that. .content{ display: grid; grid-template-columns: 25% 25 ...

The line break refuses to concatenate

I've been grappling with trying to format and print a 9x9 2D JavaScript array into a grid, but for some reason I can't seem to get the line breaks right. Instead of displaying the array in a neat square grid, it's all coming out in a single ...

The width of DIVs in Mac Safari exceeds that of other browsers

Encountering an issue that is specific to MAC Safari. Here's the code snippet: <div class="wrapper" style="max-width:1220px"> <div style="width:50%;display:inline-block">First</div> <div style="width:25%;display:inline-block"&g ...

When the React component's state is updated, an animation is triggered in a subcomponent connected to the parent component

The ProjectsSection component is responsible for rendering a document section with a header and cards. The goal is to trigger a header animation only when the header becomes visible on the screen for the first time and have it run once. However, adding a s ...

Adjusting the style attributes for Material-UI Icons

I could use some assistance with changing the CSS property of MUI icons in order to assign a specific color when the icon is focused. I have implemented the icons in the header and am displaying different pages below them, so I would like to give each ac ...

I require the flexbox children to be arranged in a regular manner

How can we set flexbox children to default layout behaviors? Let's make them behave like the disobedient kids they are. .wrapper { This should be a row } .column { Make all heights equal display: flex; } .child { Back to regular display...wit ...

My navbar in bootstrap is having trouble staying aligned with the button and search box. What can I do to ensure everything stays in line?

<nav id="NavbarMaster" class="navbar NavCompression"> <!-- style="min-height:100px;" --> <div id="navToggler" class="container-fluid TitleBG TitleHeight"> <div id="navopener" class="Pointer" style="position:fixed;top:0;left:0; ...

The toLowerCase method seems to be malfunctioning along with several other functions

JS var score = 0 var yes = "yes" var pokemonName = []; var bg = []; var index = 0; document.getElementById('repete').style.visibility = 'hidden'; (function asyncLoop() { background = bg[num = Math.floor(Math.random() ...

What is the best method for deleting an uploaded image from a box?

My code is quite lengthy, so I'll just showcase the JavaScript portion here. Here is a snippet of my JavaScript code: <script type="text/javascript"> let current = 0; for(let i = 0; i < 5; i++) { $('#thumbnail-view- ...

Adjust the image size to match the height of the frame

Working on a website where I want to incorporate a frame at the bottom of the screen, taking up 10% of space. I envision placing a logo within that frame, which seems straightforward. However, here is where it gets tricky. Since this frame's size de ...

What is the best way to add three dots at the end of text when it exceeds the available space?

What CSS property is utilized to display three dots at the end of text when it overflows? ...