PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, October 15, 2022

[FIXED] How can I limit the div (autocomplete-item) created by JS for autocomplete search?

 October 15, 2022     css, dom, dom-events, javascript     No comments   

Issue

I have created a autocomplete search box using the code in the link: w3schools

I am using a list of 3000 cities (JSON file). When performing the search, the search list is too long. How can I limit the size of the divs being created by JS or even set a fixed height for the division containing that list and make it scrollable?

I really appreciate any help you can provide.


Solution

You can add max-height to the outer div and handle the overflow

.autocomplete-items {
    max-height: 200px;
    overflow-y: scroll;
}


Answered By - Abito Prakash
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,214,505

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing