SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Location
    Dublin, Ireland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE simulated text-shadow flows separately from its text

    I've asked this question in another popular forum (here) and was surprised not to have a single response in 2 weeks, maybe because it was tagged as a "jQuery" issue although fundamentally a CSS & cross-browser issue. I am certain a solution will be useful to the SitePoint community and beyond.

    I've been using jQuery and IE filters to create a text shadow in IE<=9, to make up for the missing text-shadow property. This can be seen in the top-of-page h2 headings on the site http://area11aa.ie, which uses jQuery on browsers that don't support the text-shadow property (detected by modernizr) to replicate the text inside the h2 element...
    Code:
    jQuery(".no-textshadow h1, .no-textshadow h2").each(function(){
      var text_shadow_markup = jQuery(this).html();
      jQuery(this).append("<span class='shadow'>"+text_shadow_markup+"</span>");
    });
    ...where it is styled with this CSS, as per this IE drop shadow technique:
    Code:
    @media only screen and (min-width: 768px) {
      h2 {
        text-shadow: #000000 0px 5px 5px;
        position: relative;
        zoom: 1;
        z-index: 1;
      }
      h2 span.shadow {
        color: #000000;
        position: absolute;
        left: -7px;
        top: -2px;
        z-index: -1;
        zoom: 1;
        filter: progid:DXImageTransform.Microsoft.Glow(Color=#000000,Strength=2) progid:DXImageTransform.Microsoft.blur(pixelradius=5,enabled='true');
        -ms-filter: "progid:DXImageTransform.Microsoft.Glow(Color=#000000,Strength=2) progid:DXImageTransform.Microsoft.blur(pixelradius=5,enabled='true')";
      }
    }
    The problem: Depending upon the screen width, the simulated drop shadows flow independently of the text behind them. You can always see this in IE8 and IE9 by slowly changing the window width until one of the shadows pops away from its text, like this (screenshot from IE9):
    bad-shadow.png
    I don't understand how this can happen if the shadow span is absolutely positioned in the containing box of the h2 element. Yet they are able to flow as if they were unattached. I realise this may be a browser bug and therefore would be happy with a workaround supporting IE8 & IE9, as I would be if someone can point out any problems with my application above.

    I've heard that CSS Sandpaper text-shadow implements a similar technique. In the next few days I'm about to test to see if it has the same problem... if it does, our next design is totally screwed.

    I would therefore love to know if 1) if there is a best-practice way of dealing with this problem, and 2) failing a more general approach, if anyone has tested CSS Sandpaper enough to know if it's free from this vulnerability & could be endorsed as a best-practice solution.
    Last edited by rphair; Apr 2, 2013 at 09:30. Reason: attachment not aligned properly


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •