Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make buttons same size?

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
Dear Friends:
I am designing a page using ASP. I would like to have several buttons in one part of the frame. I can not make then the same size and can not position them. Your help is highly appreciated.

Haijun
 
Generally the size of button control on HTML page is proportional to the value of the control (number of letters on the control). Do we have method to make them same size regardless of the number of letters.

Haijun
 
Yes we do. You have to use CSS property named [tt]width[/tt]. Here's an example:

<style>
.btn1 { width: 150px }
</style>

. . .
<input type=&quot;button&quot; class=&quot;btn1&quot;>

Using CSS you can also define other settings like button color and text size/font/style.

good luck
 
Not only that, but when I used width on some buttons in NS 6 the stupid browser decided to make them stack vertically instead of leaving them both on the same line! I STILL haven't figured that one out!

My best advice, add
Code:
&nbsp;
to either side of the shorter ones until they look about the same size as the longest one. It's not an ideal solution, but it works.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Duh, I guess I should have previewed that posting, but I put it in code tags and it STILL interpreted it. It should have said
Code:
&nbsp;
. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Oh well, I guess there's no reasonable way to make it work. That time I used
Code:
(an ampersand)amp;nbsp;
and it previewed correctly, but it STILL won't display correctly. Let's try it will a bunch of spaces:
Code:
& n b s p ;
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Don't ya just love the way this thing PREserves code...NOT :)

[pre]&bnsp;[/pre] <-- test about here but we all *know* nothing will show up - or we'll get an added ; like in the php forum. ***************************************
Party on, dudes!
[cannon]
 
so is there anyway to size buttons with more precision for cross-browser use? I am having the same problem. Also font sizes seem to vary from computer to computer. For instance, I use 3 buttons placed horizontally and then put a table below, making the width of the table the same as the width of the 3 buttons. However when viewed on another computer the widths are no longer the same.
 
I thought for a minute that karver had figured out a way to make TT display that darned code right, then I looked again and realized that he transposed the first two characters, so no wonder it didn't get mucked up.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Doh! sussed, well spotted Tracy :) ***************************************
Party on, dudes!
[cannon]
 
You can control font properties of the text appearing on button face. It works in all browsers including NN4.x

<style>
.btn1 { width: 150px;
font: bold 12pt verdana, arial, sans-serif }
</style>

This example works completely in IE5+, Opera 5/6, Mozilla/Netscape 6.
NN4.x shows the same font properties like all other browsers, but doesn't show the width specified in stylesheet.

You can also add color for text and backgrond, but this will work only in IE and Mozilla/Netscape 6.

Also, NN4.x is the only one that prevents button placement in one line. But I don't see any trouble here - use a simple table and you'll solve the issue.

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top