/    Sign up×
Community /Pin to ProfileBookmark

Set size of <select> tag

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,

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@SavoryMediaNov 23.2005 — 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.
Copy linkTweet thisAlerts:
@Marlon_BrauthorNov 23.2005 — 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.
Copy linkTweet thisAlerts:
@toicontienNov 23.2005 — The following code worked for me in IE6-WinXP:
[code=html]<!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>[/code]
×

Success!

Help @Marlon_Br spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...