Sathish
Sathish

Reputation: 2460

how to make transition effects(slide) in autocomplete

autocomplete working fine but i need a transition effect(slide down) in suggested menu,

I referred from this sites http://tutsforweb.blogspot.in/2012/05/auto-complete-text-box-with-php-jquery.html

and i tried

 $(document).ready(function() {
   $("#tag").autocomplete("autocomplete.php", {
     selectFirst: true
   });
 });
.ac_results {
  background-color: white;
  border: 1px solid #5c5c5c;
  left: 174.5px !important;
  overflow: hidden;
  padding: 0;
  width: 247px !important;
  z-index: 99999;
}
.ac_results ul {
  width: 100%;
  list-style-position: outside;
  list-style: none;
  padding: 0;
  margin: 0;
}
.ac_results li {
  margin: 0px;
  padding: 2px 5px;
  cursor: default;
  display: block;
  font-family: "armataregular";
  font-size: 12px;
  line-height: 16px;
  overflow: hidden;
}
.ac_loading {
  background: white url('indicator.gif') right center no-repeat;
}
.ac_odd {
  background-color: #eee;
}
.ac_over {
  background-color: #ccc;
  color: black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="listone">
  <input type="text" placeholder="Enter Keyword" id="tag">
</div>

I added transition property on id="tag" and .ac_results its not working, please suggest any idea.,

Upvotes: 0

Views: 1181

Answers (1)

RSquared
RSquared

Reputation: 1188

Transitions work by listening to a property and will "animate" when that property changes. So in your case you would need to add a transition to #ac_results. Set the #ac_results height to 0, and when it finds results change the height that element and it should slide down

transition: height 0.5s ease-in-out;
height: 0;

Here is a quick example of it (note that it doesn't do any auto complete, just it shows when input is detected)

http://jsfiddle.net/schwqa7k/1/

Upvotes: 1

Related Questions