views:

479

answers:

3

I have few buttons on my jsp page and I am using the style as :

*.buttonblue {
    background-color: #003366;
    border-color: #99CCFF;
    color: #FFFFFF;
    font-family: Verdana,Arial,Helvetica;
    font-size: 8pt;
    font-weight: bold;
    height: 20px; 
    display:inline;
    line-height: 1.2;
    text-align: center; 
         margin-top: 2px; 
}*

In Firefox the buttons are bit smaller than IE6. I can not define the size of buttons as the caption changes the button size changes accordingly.

I tried with width:auto but no success. Also, with overflow:visible the buttons in IE becomes bit smaller.

Please help.

+2  A: 

IE has a bug with button padding, you may be experiencing this. Try something like this:

input.button {
    padding: 0 .25em;
    width: 0;  /* IE table-cell margin fix */
    overflow: visible;
}

input.button[class] {  /* IE ignores [class] */
    width: auto;  /* cancel margin fix for other browsers */
}

Note: if your buttons become even smaller in IE after applying this fix, make sure you are not in quirks mode. In IE's quirks mode the widths of objects are calculated differently than in standards mode, making everything a bit smaller (for items with a specified width). Best to always use standards mode if you expect consistent cross-browser results (even though IE's standards mode isn't that good, it's still way more standard than quirks mode).

Mr. Shiny and New
There is another issue I see now. The size of buttons in IE not less than the FF. I added #width:0; overflow: visible; in IE the button caption tightly aligned on left and right side like 'Submit' where as in FF there is some space on left and right side like ' Submit ' (see the space). I tried with align:center; in css, but does not work.
Anurag
@Anurag: please ask a new question if you have a new problem. And include a short sample of the code which demonstrates the problem, including the HTML.
Mr. Shiny and New
@Mr. Shiny and New: I am using the below styles for button. .buttonblue { background-color: #003366; border-color: #99CCFF; color: #FFFFFF; font-family: Verdana,Arial,Helvetica; font-size: 8pt; font-weight: bold; height: 20px; line-height: 1.2; text-align: center; margin-top: 2px; #width:0; overflow: visible; } with this I see the offsetwidth is 16px more than the width, Hence in FF i see the button size slightly larger with spaces at left and right side. Which looks like similar to the Add Comment button on this page.
Anurag
@Anurag: looks like maybe you need to specify the padding on the buttons for a consistent look.
Mr. Shiny and New
Thanks. This was exactly the answer I was looking for. It works perfectly when I am trying this with IE8 currently running in IE7 standards mode
Jesper Rønn-Jensen
@Mr. Shiny and New: I tried with padding. They look ALMOST similar in IE and FF. Thanks all for your response.
Anurag
@Anurag: You will need to play with the padding, margin, border, outline, font size, and line-height, and test in several IE versions, to get a consistent look. But I don't think you can guarantee pixel-perfect sizing even if you specify everything. The best you can hope to achieve is "looks good in all supported browsers". If you are worried about accessibility you may also want to try zooming the page size or adjusting the font size (people with poor eyesight use page zoom or font zoom a lot).
Mr. Shiny and New
A: 

A button is rendered however the browser decides. You will need to use an image and set it up to work like a button if you want it to look that same in all browsers.

thecoshman
Sure, the specific appearance of the unstyled button is browser or platform specific, but the WIDTH of the button should be in the control of the page designer, and is, for all browsers anyone cares about. If you style the button so that the default styles are no longer used then you can even make them the same on all browsers without images. The sites I maintain currently do this and it works quite well. We just have to add some CSS fixes for IE6's bugs.
Mr. Shiny and New
Ah your right, I missed the point of the question.
thecoshman
Thanks a lot guys. Finally I got a combination from all your comments and it works .... whooa whooa !! I am using like this : #width:0; overflow: visible; we can ignore width:auto as FF will take it by default. Thanks a lot again :) :)
Anurag
There is another issue I see now. The size of buttons in IE not less than the FF. I added #width:0; overflow: visible; in IE the button caption tightly aligned on left and right side like 'Submit' where as in FF there is some space on left and right side like ' Submit ' (see the space). I tried with align:center; in css, but does not work.
Anurag
@thecoshman: I see some offsetWidth is set in FF. which result in extra space before and after the text displayed on button.can we set the offsetwidth for IE.
Anurag
@Anurag bit out of touch with this question. Sot his may be a rather random comment, but you may want to look into a CSS 'reset' sheet. All browser like to add their 'flair' to a 'standard' page, such as chrome likes to add a highlight to a focused form element. These are like 99% always CSS based, thus you can override them. It may help you to have a some CSS rules at the very top, that reset all margins and paddings to 0, as an example. Read up on this, you will soon see what I am on about.
thecoshman
+3  A: 

Either use Conditional Comments :

Ex:

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

Or set custom width for input only read by IE like this :

    .buttonblue { 
background-color: #003366; 
border-color: #99CCFF; 
color: #FFFFFF; 
font-family: Verdana,Arial,Helvetica; 
font-size: 8pt; 
font-weight: bold; 
height: 20px; 
display:inline; 
line-height: 1.2;
text-align: center; 
margin-top: 2px; 
width: 100px; /* Read by FF */
#width:100px; /* Read by IE*/
}

Now you can tweak them accordingly

c0mrade
Thanks a lot guys. Finally I got a combination from all your comments and it works .... whooa whooa !!I am using like this :width:auto;#width:0;overflow: visible;
Anurag
@Anurag Hey, if this answer did help you, you ought to select it as the best answer by clicking the green checkbox next to it. Just a friendly suggestion, that's all.
Matt Blaine
There is another issue I see now. The size of buttons in IE not less than the FF.I added #width:0; overflow: visible;in IE the button caption tightly aligned on left and right side like 'Submit' where as in FF there is some space on left and right side like ' Submit ' (see the space).I tried with align:center; in css, but does not work.
Anurag
@Anurag without any live demo or code, no one can speculate or guess what the real problem is
c0mrade