Skip to content

Instantly share code, notes, and snippets.

@anddoutoi
Created November 7, 2011 15:23
Show Gist options
  • Save anddoutoi/1345268 to your computer and use it in GitHub Desktop.
Save anddoutoi/1345268 to your computer and use it in GitHub Desktop.
A somewhat working patch for ie7 button width issues
.ie7 button,
.ie7 input[type="button"],
.ie7 input[type="reset"],
.ie7 input[type="submit"]
{
margin: 0;
padding: 0 15px;
overflow: expression(
this.style.overflow = 'visible',
this.style.pixelWidth = function (w) {
var b, c;
if (0 == w) {
// element is probably hidden
b = document.body;
c = this.cloneNode(true);
c.runtimeStyle.cssText = 'position: absolute; visibility: hidden;';
b.appendChild(c);
w = c.offsetWidth;
b.removeChild(c);
}
return w;
}.call(this, this.offsetWidth)
);
}
/*
+ Only evaluates expression once per button!!!1011 (Not that much performance penalty, that is)
+ Works for buttons in table cells
+ Works for hidden buttons
- Fails if JScript is disabled
- Fails if a new longer text string is set from script, but who the **** does that?!? ;)
- Fails for buttons inserted dynamically
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment