How can I set the width of select html element, without considering of each option width
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
Actually I know the select box width
is set by the longest option in the list, but I want to increase the length (width) of a select
html element.
I also searched and I understand this code style="max-width:70%"
may work but it doesn't work for me.
the blow code is mine:
<select class="form-control"style="max-width:70%">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
Thank you for your responding.
html html-select dropdown
add a comment |Â
up vote
6
down vote
favorite
Actually I know the select box width
is set by the longest option in the list, but I want to increase the length (width) of a select
html element.
I also searched and I understand this code style="max-width:70%"
may work but it doesn't work for me.
the blow code is mine:
<select class="form-control"style="max-width:70%">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
Thank you for your responding.
html html-select dropdown
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
Actually I know the select box width
is set by the longest option in the list, but I want to increase the length (width) of a select
html element.
I also searched and I understand this code style="max-width:70%"
may work but it doesn't work for me.
the blow code is mine:
<select class="form-control"style="max-width:70%">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
Thank you for your responding.
html html-select dropdown
Actually I know the select box width
is set by the longest option in the list, but I want to increase the length (width) of a select
html element.
I also searched and I understand this code style="max-width:70%"
may work but it doesn't work for me.
the blow code is mine:
<select class="form-control"style="max-width:70%">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
Thank you for your responding.
html html-select dropdown
html html-select dropdown
asked 44 mins ago


Niusha Ghanbari
507
507
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
4
down vote
accepted
you should use width
attribute instead of max-width
.
correct your code to below sample:
<select class="form-control"style="width:150px">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
You have to use css property min-width
for increasing width of dropdown irrespective of the width of options.
html:
<select class="dropdown">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
css:
.dropdown
min-width: 200px;
add a comment |Â
up vote
0
down vote
This will help you.
<select class="form control"style="width:70%">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
you should use width
attribute instead of max-width
.
correct your code to below sample:
<select class="form-control"style="width:150px">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
4
down vote
accepted
you should use width
attribute instead of max-width
.
correct your code to below sample:
<select class="form-control"style="width:150px">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
you should use width
attribute instead of max-width
.
correct your code to below sample:
<select class="form-control"style="width:150px">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
you should use width
attribute instead of max-width
.
correct your code to below sample:
<select class="form-control"style="width:150px">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 38 mins ago


Sheida Mohassesi
564
564
New contributor
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Sheida Mohassesi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
up vote
1
down vote
You have to use css property min-width
for increasing width of dropdown irrespective of the width of options.
html:
<select class="dropdown">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
css:
.dropdown
min-width: 200px;
add a comment |Â
up vote
1
down vote
You have to use css property min-width
for increasing width of dropdown irrespective of the width of options.
html:
<select class="dropdown">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
css:
.dropdown
min-width: 200px;
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You have to use css property min-width
for increasing width of dropdown irrespective of the width of options.
html:
<select class="dropdown">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
css:
.dropdown
min-width: 200px;
You have to use css property min-width
for increasing width of dropdown irrespective of the width of options.
html:
<select class="dropdown">
<option value="1">option 1 </option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
css:
.dropdown
min-width: 200px;
answered 40 mins ago


AkshayM
435212
435212
add a comment |Â
add a comment |Â
up vote
0
down vote
This will help you.
<select class="form control"style="width:70%">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
This will help you.
<select class="form control"style="width:70%">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This will help you.
<select class="form control"style="width:70%">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
This will help you.
<select class="form control"style="width:70%">
<option value="1">option 1 </option>
<option value="2">option 2sdsdsdsd</option>
<option value="3">option 3</option>
</select>
New contributor
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 24 mins ago
New contributor
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 34 mins ago


Sheikh Haziq
32
32
New contributor
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Sheikh Haziq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53031489%2fhow-can-i-set-the-width-of-select-html-element-without-considering-of-each-opti%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password