views:

494

answers:

6

Greetings. I'm having troubles with the following legacy code. It's fine in everything except IE7, where the submit button disappears. Space is still left for it on the page, but it doesn't show. I've tried various ways of forcing hasLayout, but without success. Any suggestions?

XHTML (XHTML 1.0 Strict DOCTYPE):

<div id="headerFunctionality" class="clearfix">
<div id="headerSearch" class="clearfix">
<form action="http://foo.com" method="GET">
<label for="q">Search</label>
<input id="q" name="q" type="text" class="text" />
<input type="submit" id="btn_search" value="Search">
</form>
</div>
</div>

CSS:

#headerFunctionality {
    float: right;
    display: inline;
    margin: 24px 14px 25px 0; 
}

#headerSearch{
    float: left;
    margin-left: 20px;
    width: auto;
}

#headerSearch label{
    position: absolute;
    top: -5em;
    color: #FFF;
}

#headerSearch input.text{
    width: 133px;
    height: 18px;
    border: 1px solid #999;
    font-size: 0.69em;
    padding: 2px 3px 0;
    margin: 0 6px 0 0;
    float: left;
}

/* Replace search button with image*/
input#btn_search {
    width: 65px;
    height: 20px;
    padding: 20px 0 0 0;
    margin: 1px 0 0 0;
    border: 0;
    background: transparent url(../images/btn.search.gif) no-repeat center top;
    overflow: hidden;
    cursor: pointer; /* hand-shaped cursor */
    cursor: hand; /* for IE 5.x */
}
form>input#btn_search { /* For non-IE browsers*/
    height: 0px;
}

input#btn_search:focus, input#btn_search:hover {

background: transparent url(../images/btn.search.over.gif) no-repeat center top;

}

A: 

Is this any help?

http://www.kalzumeus.com/2009/10/23/the-ie-css-bug-which-cost-me-a-months-salary/

Chris
I read this recently but hadn't made the connection 'til you mentioned it. It does sound like the same issue, which makes me think it's 'known' and there's a fix, but the TFA doesn't say what it is!
da5id
+1  A: 

There are two things I can see from the code that could cause this:

1 - the image btn.search.gif is either completely transparent, the colour of the background or not found. The button has no background colour and no border, so would not appear if not for the image/text

2 - the button visibility is set to none, which leaves space on the page but doesn't render the button. Can you look at the styles in firebug?

adam
Hah, my first thoughts too, but unfortunately neither of these. I've even tried setting visibility explicitly to "visible". The issue is *only* in IE7.
da5id
A: 

if you add a name attribute, does it work?

scunliffe
Cheers, good thought, but sadly no :(
da5id
A: 

The problem likely comes from the Guillotine Bug. It's a bug in IE6 and IE7 that occurs when certain mixtures of :hover, float, and layout are present (see link for details). I believe that inserting this:

<div class="clear"><!-- --></div>

right before </form> and then applying the following CSS to it:

.clear {clear:both;}

would fix it.

sfarbota
da5id
A: 

I finally sorted this by removing the:

form>input#btn_search { /* For non-IE browsers*/
    height: 0px;
}

I had always included this with CSS image replacements after reading it somewhere ages ago, but leaving it out doesn't seem to have affected any other browser and has fixed the problem in IE7.

da5id