Input boxes with transparent background are not cl

2019-01-21 16:01发布

I have an absolutely positioned input box in a form. The input box has transparent background:

.form-page input[type="text"] {
    border: none;
    background-color: transparent;
    /* Other stuff: font-weight, font-size */
}

Surprisingly, I cannot select this input box by clicking on it in IE8. It works perfectly in Firefox however. The same happens for background: none. When I change the background color:

    background-color: red;

It works fine, so this is issue associated with transparent background. Setting a border makes the input box selectable by clicking on its border only.

Is there a workaround to have clickable input box with transparent background working in IE8?

Update: Example. Uncomment background-color and the inputbox is selectable. You can also click on the select box, and focus the input box by pressing Shift+Tab.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head></head><body>

<style type="text/css">
  input[type="text"] {
    border: none;
    background: transparent;
    /*background-color: blue;*/
  }
  #elem528 { position:absolute; left:155px; top:164px; width:60px; height:20px; }
  #elem529 { position:absolute; left:218px; top:164px; width:40px; height:20px; }
</style>

<img src="xxx.png" alt="" width="1000" height="1000">
<input id="elem528" maxlength="7" type="text">
<select id="elem529"></select>

</body></html>

14条回答
做自己的国王
2楼-- · 2019-01-21 16:45
 background-image:url(about:blank);background-color:transparent;
查看更多
Bombasti
3楼-- · 2019-01-21 16:47

I've found the same issue using IE10 on Windows 7. Both of the following methods fixed the issue for me.


Franky's method using a transparent background image...

background:url(/images/transparent.gif);


Sketchfemme's method using an rgba background colour with '0' opacity

background-color:rgba(0,0,0,0);


Jim Jeffers suggestion for editing the z-index's did not work for me.

查看更多
登录 后发表回答