2 replies [Last post]
thoffman777
Offline
newbie
Last seen: 16 years 21 weeks ago
Joined: 2004-07-09
Posts: 2
Points: 0

Hi -

I'm building a site driven by ASP and need to automatically resize input buttons:

<input type="button" id="btn1" value="<%=btnValue%>" style="width:?px">

to be just the right size to show the value. That way the button wouldn't be too big or too small. Is there a way to set that with CSS? Or do I have to implement some Javascript code?

Any help would be great! Thanks!

co2
co2's picture
Offline
Leader
UK
Last seen: 12 years 33 weeks ago
UK
Joined: 2003-09-17
Posts: 721
Points: 0

Automatically resize an input button to it's value :?:

If you don't specify a size (width), then the button will size itself to its title length.

The next sentence is true. The previous sentence is false. Discuss...

thoffman777
Offline
newbie
Last seen: 16 years 21 weeks ago
Joined: 2004-07-09
Posts: 2
Points: 0

Automatically resize an input button to it's value :?:

That's what I tried at first but they would look something like this:

<input type='button' id='button1' value='button1'>

But then I did this:

<input type='button' id='button2' value='button2' style='width:100%;height:100%;border:none;background-color:#ffffff;padding:0px;font-family:arial;font-size:12px;color:#0000ff;'>

And it seems to work... I'm basically trying to make an input button look like a link...