Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE crossing out pseudo element CSS?

I've been trying to get a few pseudo elements to work on IE, but it just doesn't let me.

It crosses out the CSS and acts like it's not there, which kinda aggrevates me.

Would anyone know what I'm doing wrong?

.newbutton {    border-radius: 50%;    width: 74px;    height: 74px;    position: relative;    background-color: black;    margin: 60px 0px 25px 17px;    overflow: visible;  }    .newbutton:before {    content: "f";    width: 80px;    height: 80px;    position: absolute;    border-radius: 50%;    z-index: -1;    top: 37px;    left: 37px;    -webkit-transform: translate(-50%, -50%);    transform: translate(-50%, -50%);    -webkit-animation-name: fadecolor;    -webkit-animation-duration: 5s;    -webkit-animation-iteration-count: infinite;    animation-name: fadecolor;    animation-duration: 5s;    animation-iteration-count: infinite;  }    .newbutton:after {    content: "";    width: 80px;    height: 80px;    position: absolute;    border-radius: 50%;    z-index: -2;    top: -3px;    left: -3px;    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#01BAE8), to(#0183D5));  }
<div class="starttour">    <div class="newbutton headerbutton">      <span class="iconhead icon-02-arrow-icon"></span>    </div>    <p>START TOUR</p>  </div>

Screenshot of what happens:

like image 836
Kairowa Avatar asked Jan 10 '15 10:01

Kairowa


People also ask

Can you combine pseudo selectors?

If you're talking about pseudo-classes, then yes, you can combine them in any order.

Can you have two pseudo elements?

1, an element can only have at most one of any kind of pseudo-element at any time. (This means an element can have both a :before and an :after pseudo-element — it just cannot have more than one of each kind.)

Can pseudo elements and pseudo-classes be combined?

There are no special rules around combining pseudo-classes and pseudo-elements, besides the one rule that says there can only be one pseudo-element per complex selector and it must appear at the very end.


2 Answers

This is a known issue, but the styles are in fact being applied. The developer tools thinks the pseudo-element styles are being overridden by the parent-elements corresponding styles. This is easily demonstrated by inspecting the Computed style of the parent-element and looking at (what the F12 tools believe to be) competing styles:

enter image description here

Again, however, these styles are in fact being applied to the correct elements - regardless what the developer tools believe or suggest. You can confirm this by running over the parent-element and the two pseudo-elements and logging their computed height:

(function () {      var el = document.querySelector( ".newbutton" );      [ "", "::before", "::after" ].forEach(function ( e ) {         // Output: 74px, 80px, 80px         console.log( window.getComputedStyle( el, e ).height );     });  }()); 

I'll check to see if we already have an internal issue tracking this bug, and add this question to it. Generally speaking, we try to give issues like this the amount of attention proportional to the amount of grief the issue is causing in the real world. So having your question as a new addition on the ticket may help us move a fix forward :)

like image 52
Sampson Avatar answered Sep 21 '22 18:09

Sampson


I had this exact same issue! You must give your :before and :after pseudo elements a display property.

Add the following to the :before and :after.

display: block;  

This should fix your issue. :)

like image 35
Freddie Avatar answered Sep 22 '22 18:09

Freddie