Click to See Complete Forum and Search --> : Set size of <select> tag
Marlon_Br
11-23-2005, 08:58 AM
Hello,, I need help on how to set the size of the select tag to fit the size of itīs content, horizontally speaking. And to keep a minimum width whenever there is no content in it. I'm using: style="width:198px;" but the content sometimes exceeds this size.
Thanks,
SavoryMedia
11-23-2005, 11:00 AM
I currently know of no easy way to do this until the CSS spec comes out with "min-width" attributes.
You might be able to do it with JavaScript+CSS, but I'm a beginner when it comes to JS.
Marlon_Br
11-23-2005, 12:23 PM
Thanks for the response, I actually had tried that, the only problem is that it only works on Fox, doesnīt work on IE.
try this to see;
<html>
<head>
</head>
<body>
<br>
<select multiple="multiple" size="5" style="min-width:320px;"> </select>
<br>
</body>
</html>
But thanks,, Iīll keep trying different things.
toicontien
11-23-2005, 02:28 PM
The following code worked for me in IE6-WinXP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>TEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
<!--
select {
width: 100%;
}
-->
</style>
</head>
<body>
<select>
<option>Option 1</option>
<option>Option 1</option>
<option>Option 1</option>
<option>Option 1</option>
<option>Option 1</option>
</select>
</body>
</html>