"Csaba2000" <ne**@CsabaGabor.com> writes:
How can I dynamically resize a button in Opera?
The following code works for both IE 5.5 and NN 6.1,
but Opera 7.01 is not budging. Any ideas?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Your document type triggers quirks mode in the browsers you mention.
You should pick a document type that triggers standards mode before
you start worrying about how CSS is interpreted.
function doubleMe(elem) {
var myWidth = elem.offsetWidth;
elem.style.width = 2 * myWidth; // NN
elem.style.posWidth = 2 * myWidth; // IE
Try
elem.style.width = (2 * myWidth) +"px";
Buttons might be seen as inline elements, so setting the width won't
do anything in standards mode, and apparently not in Opera quirks mode
either. This is the desired behavior for inline elements.
This is confuzing, since the CSS 2.1 working draft suggested HTML
style sheet sets buttons to be inline-block elements, where the width
should work. maybe it is just an Opera bug.
To change the width, you must make it a block element. This differs
from input elements of type "button", which are *replaced* inline
elements, and therefore respect the width setting (like images).
Alertnatively, you can give it a padding:
elem.style.padding = "0px "+myWidth+"px";
This won't double the size exactly, but will set the padding
on each side to the current size of the entire button.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'