IE8 Bug AlphaImageLoader

by Brahim Hamdouni

HTML

<p class="message">
    Because of an IE 8 Bug, you can't click on links or inputs inside a div <br/>
    with a background image set by AlphaImageLoader filter. <br/>
    Try below to click on the link, the button or the text input.<br/>
    To fix it, make an inside div with a css 'position: relative'.
    <button class="fixit" onclick="fixIt()">Fix it ! </button>
    <br/><br/>
    <a href="http://jsfiddle.net/hamdouni/w4BBE/">JSFiddle</a> : don't edit with ie8, it doesn't work !
</p>
<div class="logondesktop">
    <div class="logon" id="theElementToFix">
        <form>
            <label>login: </label> <input type="text"/> 
            <label>pass: </label> <input type="password"/> 
            <div class="actions">
                <a href="#">Forget ?</a> | <button>Log me in</button>
            </div>
        </form>
    </div>
</div>

CSS

/* add the background with the filter for IE */
.logondesktop { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( enabled=true, src='http://lorempixel.com/1200/800/', sizingMethod='scale');}

/* Tofix the IE8 bug on links with background image set by AlphaImageLoader 
.logon {
    position: relative;
}
----------------------------------------------------------------------------*/ 

/* make the example less ugly */
html, body, .logondesktop {height: 100%; width: 100%; border: 0; padding: 0; margin: 0; font: 16px 'Arial';}
.message {background: white;position: absolute;top:0;padding:14px 28px;}
.logon {background-color: #eee; margin-top: 20%; margin-left: 40%; padding: 16px 32px; width: 260px;}
.logon .actions {text-align: right; }
.logon label {width: 50px;display:inline-block;}
.logon input {width: 200px;}

JavaScript

fixIt = function() {
    var theEl = document.getElementById('theElementToFix');
    theEl.style.position = 'relative';
}