htmlcss

  1. Lies, lies, and Android’s stock browser

    While working on a responsive site that featured some CSS 3D Transforms, I found that, for some reason, clicking into a text input to type on Android 2.3 and below caused the automatic scroll to the input to exhibit a strange yoyo behavior. It would jump down about 300px too far, jump up a bit, jump down again, up one more time, and park itself a couple of hundred pixels south of the actual input location.

    After a ton of messing around, I realized that it was related to another bug: the stock Android Browser’s incomplete support for CSS 3D Transforms and transitions.

    Despite Modernizr reporting that it’s supported, Android 2.3 and below will in fact fail to properly perform a rotateY transform, instead performing a regular rotate. Additionally, the very presence of an element with 3D transition properties seems to cause the jumpy behavior on input focus.

    Because feature detection yields a false positive, I had to actually detect the version of Android being run via the user agent string, and add a class to the body as needed, so I could target it separately and force the fallback animation I’d written to kick in on Gingerbread, FroYo, and below (to be safe, I also added Honeycomb, since I didn’t have an Android 3 tablet to see if it worked on it).

    var ua = navigator.userAgent.toLowerCase();
    var isOldAndroid = /android [1-3]/i.test( ua );
  2. Facebook, Twitter, and IP Addresses

    Some things I have learned:

    If your server doesn’t have a domain name yet (for example, while working on a production server and website to replace an existing website/server which is currently using the domain name), Twitter and Facebook act weird.

    Twitter’s share button fails outright saying you didn’t pass it a url (even though you did).

    And Facebook fails to load the image thumbnail from its share widget, even if you have all of your OpenGraph tags filled out correctly. Note that it will lint it correctly, and post it correctly, but when you hit share, you won’t see the thumbnail.

    Just felt I should share…

  3. On Z-Index

    Common issue but one that I often forget and see people asking about:

    The z-index css property does not work on static positioned elements (the default positioning). Make it at least position: relative to make z-index do something.

  4. A Javascript-less Image Viewer

    So a while back, I was tasked with making what essentially boiled down to an image-viewer. The catch? I had to make it work without javascript (for Internet Explorer in particular), and it had to be done without reloading the entire page.

    Sounds weird, I know, but blame Valve for using Internet Explorer 6, sans javascript, as their HTMLView object in the Source Engine SDK. Anyway… It sounds difficult, but it’s really not, it’s actually very VERY simple, it’s just easy to overthink.

    First of all, you’re going to have to make sure all of the images are the same size, or at the very least, the same height. You’re going to block out the HTML like so:

    <div id='slideshow'>
         <img id="image1" src="imgimage1.jpg" alt="Image 1" />
         <img id="image2" src="imgimage2.jpg" alt="Image 2" />
         <img id="image3" src="imgimage3.jpg" alt="Image 3" />
         <img id="image4" src="imgimage4.jpg" alt="Image 4" />
    </div>
    <div id='slideshowNav'>
         <a href="#image1">Image 1<a>
         <a href="#image2">Image 2<a>
         <a href="#image3">Image 3<a>
         <a href="#image4">Image 4<a>
    </div>

    The key here is the fact that all of the images have their own id values. Now the css is going to look like so:

    #slideshow{
         width: Width of your widest image;
         height: Height of the images;
         overflow: hidden;
    }

    Now the end result is you have the slideshow div acting as a sort of “viewing window” through which you’re looking at the images. Each image has an id value associated with it, and clicking the link jumps to that image in the slideshow div.

    I should note that last I checked, Opera has a problem with overflow hidden and scrolling, but it’s a known bug in Opera and is in fact even a part of the Acid2 test, so I believe Opera 10 should work fine with this trick.