Cleveland Web Design by Designing Interactive

May 1, 2008

Fixing Disappearing Cursors in Firefox

By: Josh Walsh in Code

The past few days I have been debugging the User Interface for Simpli5. Today I wrestled with a particularly frustrating issue in which cursors were completely vanishing from inputs in Firefox. While it did not affect the interaction of the input, I could still manipulate the text, it did cause quite an annoyance.

Here is a quick example which demonstrates the problem:

    <div id="Container" style="position:absolute; left: 0; top:0; width: 100%; height:100px; background: #900; overflow: scroll;">
    </div>
   
    <div id="Dialog" style="position:absolute; top:10px; left: 10px; width: 300px; z-index: 1">
        <input name="Username" type="text" />
    </div>

The problem is caused by the change in Firefox’s current rending frame. Setting overflow:scroll on our #Container div causes Firefox to use that div as it’s current rending frame. Thus, the cursor is being rendered on the #Container, not on the #Dialog div, which contains the input. Effectively, the input is covering its own cursor.

The fix is a simple change in CSS inheritance. Without setting an overflow setting on the #Dialog div, we are inheriting the overflow:scroll from #Container. By setting the #Dialog div’s overflow setting back to it’s default overflow:auto we are changing Firefox’s rendering frame to the #Dialog div, thus bringing back our cursor.

Here is the fixed example:

    <div id="Container" style="position:absolute; left: 0; top:0; width: 100%; height:100px; background: #900; overflow: scroll;">
    </div>
   
    <div id="Dialog" style="position:absolute; top:10px; left: 10px; width: 300px; z-index: 1; overflow:auto;">
        <input name="Username" type="text" />
    </div>

Thankfully, Mozilla has fixed this problem in Firefox 3.

Comments

Author Gravatar

Seth Keiper » May 6, 2008

This seems to be “fixed” in FF3. Great post!