我想讓類別列表顯示大約7個選項,其餘的滾動,因爲列表很長,滾動頁面。我試圖做css溢出,但我不知道在哪裏做。如何使html datalist溢出?
<form class="gameForm" method='POST' action='/game'>
<h2>CHOOSE A CATEGORY</h2>
<input type="text" list="category" name="category" placeholder="Category">
<datalist id="category">
<option value="any">Any Category</option>
<option value="9">General Knowledge</option>
<option value="10">Entertainment: Books</option>
<option value="11">Entertainment: Film</option>
<option value="12">Entertainment: Music</option>
<option value="13">Entertainment: Musicals & Theatres</option>
<option value="14">Entertainment: Television</option>
<option value="15">Entertainment: Video Games</option>
<option value="16">Entertainment: Board Games</option>
<option value="17">Science & Nature</option>
<option value="18">Science: Computers</option>
<option value="19">Science: Mathematics</option>
<option value="20">Mythology</option>
<option value="21">Sports</option>
<option value="22">Geography</option>
<option value="23">History</option>
<option value="24">Politics</option>
<option value="25">Art</option>
<option value="26">Celebrities</option>
<option value="27">Animals</option>
<option value="28">Vehicles</option>
<option value="29">Entertainment: Comics</option>
<option value="30">Science: Gadgets</option>
<option value="31">Entertainment: Japanese Anime & Manga</option>
<option value="32">Entertainment: Cartoon & Animations</option> \t
</datalist>
<h2>NUMBER OF QUESTIONS</h2>
<input class="number" name='number_of_questions' type='number' min='1' max="50" placeholder='Number of Questions' required />
<h2>DIFFICULTY</h2>
<input list="difficulty" name="difficulty" placeholder="Difficulty">
<datalist id="difficulty">
<option value="easy">
<option value="medium">
<option value="hard">
</datalist>
<input class="buttons" type='submit' value='ADD GAME!' />
</form>
你是否做了一些研究?第一次打:https://stackoverflow.com/questions/43491711/how-to-give-scrolling-effect-in-datalist-dropdown – JeroenE
不幸的是,沒有造型和html5 datalist限制。但是,您可以根據需要使用選擇並設置其大小 –