返回用jquery......登陆

用jquery做的(跟老师方法不同)

beallyoucanbe2018-11-03 03:35:19259
<!DOCTYPE html>
<html>
  
  <head>
    <title>
      下划线跟随鼠标
    </title>
    <meta charset="utf-8">
    <script type="text/javascript" src="jquery-3.3.1.js">
    </script>
    <style type="text/css">
      *{ margin: 0px; padding: 0px; } #box{ width: 500px; height: 40px; background-color:
      red; position: relative; left: 200px; top: 30px; border-radius: 5px; box-shadow:
      0px 0px 10px red; } ul li{ list-style: none; display: inline-block; width:
      120px; height: 30px; position: relative; line-height: 40px; color: #fff;
      text-align: center; } #uline{ width: 120px; height: 5px; background: green;
      position: relative; top:5px; display: none; }
    </style>
  </head>
  
  <body>
    <div id="box">
      <ul>
        <li>
          首页
        </li>
        <li>
          PHP中文网
        </li>
        <li>
          灭绝师太
        </li>
        <li>
          独孤九剑
        </li>
      </ul>
      <div id="uline">
      </div>
    </div>
    <script type="text/javascript">
      $(function() {
        $('li').mouseover(function() {
          $("#uline").show();
          $index = $("li").index($(this)) * 125;
          $("#uline").animate({
            left: $index + 'px'
          },
          50)
        }) $("li").mouseleave(function() {
          $("#uline").hide();
        })
      })
    </script>
  </body>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送