Forums

Give help. Get help.

  • # February 7, 2018 at 10:20 am

    hi guys
    why this code return undefined for me?


    var span = document.querySelector('span'); var result = window.getComputedStyle(span,':after').getPropertyValue('position'); document.write(result);
    span{
            margin:0 auto;
            font-size:40px;
            display: inline-block;
            position: relative;
        }
    span:after{
        position: absolute;
      content: "";
      border:1px solid #f30;
      left:0;
      top:55px;
      width:45px;
    }
    
    
    
    # February 7, 2018 at 10:52 am

    Working fine?

    codepen.io/JpbJRE

    # February 7, 2018 at 2:49 pm

    Only cause I can think of without seeing a demo is that you’ve put the code in the head section without a document ready wrapping function. Which means the script is executed before the page has been read (and the element “exists”).

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag