Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change display width of datalist

i have a simple issue with HTML datalist but somehow cant solve this problem. i've tried to change the displayed width for the following datalist:

<input list="browsers" name="browser">
  <datalist id="browsers">
    <option value="this is a really long name for a browser">
    <option value="Firefox">
    <option value="Chrome">
    <option value="Internet Explorer">
  </datalist>
<input type="submit">

but no matter what i try, it still cuts down the "long" option values. how can i change that, so that the datalist shows all the option values, no matter how long they are?

best regards

like image 976
user3861163 Avatar asked Aug 14 '14 11:08

user3861163


People also ask

How do you increase the width of a data list?

The only cross-browser solution is to: a) make input wider to make sure whole value is readable: JSFiddle b) use (or write) some JavaScript to emulate datalist so you can have full control over it's appearance.

Can we style Datalist in HTML?

HTML5 <datalist> elements cannot be styled.

What does Datalist mean in HTML?

Definition and Usage The <datalist> tag specifies a list of pre-defined options for an <input> element. The <datalist> tag is used to provide an "autocomplete" feature for <input> elements. Users will see a drop-down list of pre-defined options as they input data.


1 Answers

<input list="browsers" name="browser" style="width: 100px;">

  <datalist id="browsers">
   <option value="this is a really long name for a browser">
   <option value="Firefox">
   <option value="Chrome">
   <option value="Internet Explorer">
  </datalist>

<input type="submit">
like image 97
Diego Rodriguez Avatar answered Sep 16 '22 15:09

Diego Rodriguez