Home  >  Article  >  Web Front-end  >  How to use jQuery to implement a DIV that responds to the mouse sliding over and expands from bottom to top

How to use jQuery to implement a DIV that responds to the mouse sliding over and expands from bottom to top

php中世界最好的语言
php中世界最好的语言Original
2018-06-02 10:00:321395browse

This time I will show you how to use jQuery to implement a DIV that responds to the mouse sliding over and expand from bottom to top, and how to use jQuery to implement a DIV that responds to the mouse sliding over and expands from the bottom to the top. What are the precautions?, here is the actual combat Let’s take a look at the case.

2. Code

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery响应鼠标实现p由下向上展开</title>
<style type="text/css">
  .big{position:relative; width:234px; height:300px; background:#ccc}
  .show{position:absolute; display:none; bottom:0px;display:block; width:100%; height:auto; background:#f66 }
</style>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
 {
  $(".big").hover(function () {
    $(".show").stop(true,true).animate({height:"70px"});
  }, function () {
    $(".show").stop(true,true).animate({height:"0px"});
  });
});
</script>
</head>
<body>
  <!--灰色的p-->
  <p class="big">
    <!--红色的p-->
    <p class="show"></p>
  </p>
</body>
</html>

Principle:

① First, the red p passesposition:absolute Absolute positioning , and through relative and bottom positioning, such as bottom:0px.
② The bottom positioning is fixed and expands upward when the height becomes higher.
③ Use jQuery’s $().animate() animation method to control the height change of the red p.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Node.js console output log file example analysis

How to operate jQuery to realize the mouse sliding over the product The corresponding large picture

is displayed on the small picture.

The above is the detailed content of How to use jQuery to implement a DIV that responds to the mouse sliding over and expands from bottom to top. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn