Andy Mantell


  1. How to style and colour select box borders in Internet Explorer

    July 5th, 2008

    Styling and colouring select box borders in Internet Explorer has always been a bit of a problem. They’re unruly beasts that can’t be tamed with css as is possible in Firefox. In this situation, some would propose re-creating the select box using a mixture of unordered lists and javascript which has always seemed overkill to me and I’m generally not willing to do this for something as minor as a border colour.

    However, tell a designer that and I’m met with the blank stare of one who is determined not to bow to my protests of browser incompatibilities. So I’ve concocted something which I believe may be a good solution. It’s not fully tested yet as I don’t have access to IE6 here but here goes anyway:

    All select elements in this example have the following styles applied:

    select {
    height : 22px;
    border : 1px solid red;
    display : block;
    width : 150px;
    }

    The following example is a simple form with a select element styled such that it has a red border. Firefox users will see a red border but IE users will not.

    Red border applied directly to select element

    The solution I have come up with, is to wrap the select box inside a containing div and apply the following styling:

    • Red border moved onto the div instead of the select box.
    • Containing div given a height and width of 2 pixels less than the select box
    • The select box is moved up and left by 1 pixel using negative margins
    div.redBorderTest {
    overflow : hidden;
    border : 1px solid red;
    width : 148px;
    height : 20px;
    }
    div.redBorderTest select {
    display : block;
    float : none;
    margin-top : -1px;
    margin-left : -1px;
    }

    This results in the following example:

    <div class="Jul052008">
    <form>
    <fieldset>
    <legend>Red border applied directly to a containing div</legend>
    <label for="option2">Option 2</label>
    <div class="redBorderTest">
    <select>
    <option>I</option>
    <option>Like</option>
    <option>Pie</option>
    </select>
    </div>
    </fieldset>
    </form>
    </div>
    Red border applied directly to a containing div

    As of the time of writing, this has been tested working IE7 and Firefox, further tests pending… :-)

    If you aren’t happy with littering your nice markup with extra divs to fix problems that only occur in IE, then you can easily insert this extra div only for internet explorer by doing something like the following:

    <!--[if IE]> <script type="text/javascript">
    var $replaceSelect = null;
    /*
    Grab your select boxes from the document
    In this case I am only selecting the ones in the form with an id of wrapSelect
    If you want to, get all of the select elements with this line:
    var $selectBoxes = document.getElementsByTagName(’select’);
    */
    var $selectBoxes = document.forms['wrapSelect'].getElementsByTagName(’select’);

    /*Loop through them*/
    for (var $iCount=0;$iCount<$selectBoxes.length;$iCount++) {

    /*Create a wrapper div for the select element*/
    $wrapperDiv = document.createElement(’div’);

    /*Give it the right classname*/
    $wrapperDiv.className=’redBorderTest’;

    /*Insert the wrapper div after the previous sibling of the select element*/
    $selectBoxes[$iCount].parentNode.insertBefore($wrapperDiv,$selectBoxes[$iCount].nextSibling);

    /*Move the select element inside the wrapper*/
    $wrapperDiv.appendChild($selectBoxes[$iCount]);
    }

    </script>
    <![endif]–>

    This example below uses this javascript code to target IE. Firefox and other browsers will get the normal markup, with red borders applied in css. IE will get the extra div in order to apply the styles.

    Red border applied directly to a containing div which is inserted with javascript

    Hope it works for someone :-)

    Andy

  2. Spore crash to desktop caused by EA download manager

    June 21st, 2008

    Finallly, got Spore to work on my computer. It had been crashing to the desktop with no error message just after the first loading screen. After reinstalling various things trying to make it work I found that uninstalling the crappy EA download manager makes it work again. Nice one EA…

    So yeah, if anyone is having problems running the game, just uninstall the download manager and it might start working…

    Creature videos to come soon - YouTube integration is looking pretty good so far :-)

    Update:

    First (badly taken) creature video :-)

  3. Content negotiation in wordpress - serving xhtml as application/xhtml+xml

    June 11th, 2008

    Just came across a nice wordpress plugin to handle content negotiation allowing me to serve my xhtml properly. Seems to be working nicely so far with very little effort - I got firefox’s angry yellow borked screen initially but I just needed to encode some ampersands in my recent tracks widget. After that it worked fine and now I have a warm fuzzy feeling of pedanticness inside knowing my xhtml is served nicely.

    How sad am I :-)

    Part of me wanted to just serve it up and screw IE6 users but I haven’t fully research what happens when xhtml is served as application/xhtml+xml to things like JAWS and other screenreaders. I wouldn’t mind giving the finger to IE6 for all the trouble it causes me at work but I’m not prepared to cause trouble elsewhere. Time for a bit of testing I guess…

  4. Kieran Hebden and Steve Reid coming to Bristol

    June 5th, 2008

    Definately gonna have to go see this. Check this out for some pure awesomeness.

    Just found out they’re coming to Bristol in November :-)

  5. New site

    June 1st, 2008

    Finally my site is up, powered by wordpress this time after trying several different blog engines. I’ve gone with a very basic design for the moment while I finalize the markup I want to use. Hopefully I won’t have to deviate too much from this structure unless my final design changes much…

    <fires up photoshop…> :-)