• 导航特效——文字上下来回滚动


    html结构代码如下所示:

    <ul id="nav">
          <li><a href="index.html" class="home">HOME</a></li>
          <li><a href="about.html" class="about">ABOUT</a></li>
          <li><a href="photo.html" class="photo">PHOTO</a></li>
          <li><a href="works.html" class="works">WORKS</a></li>
          <li><a href="contact.html" class="contact">CONTACT</a></li>
    </ul>

    CSS代码如下所示:

    #nav {
        font-size: 1.1em;
        height: 38px;
        line-height: 38px;
        padding-top: 10px;
        float: right;
    }
    #nav li {
        margin: 0;
        padding: 0;
        overflow: hidden;
        float: left;
        height: 40px;
        width: 114px;
        display: block;
        text-align: center;
    }
    #nav li a, #nav li span {
        float: left;
        text-decoration: none;
        clear: both;
        width: 100%;
        font-family: Arial;
        font-size: 18px;
        color: #c0c0c0;
    }
    #nav li a{
        color: #90c341;
    }

    JS代码如下所示:

    $("#nav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag
        
        $("#nav li").each(function() { //For each list item...
            var linkText = $(this).find("a").html(); //Find the text inside of the a tag
            $(this).find("span").show().html(linkText); //Add the text in the span tag
        }); 
        
        $("#nav li").hover(function() {    //On hover...
            $(this).find("span").stop().animate({ 
                marginTop: "-40" //Find the span tag and move it up 40 pixels
            }, 250);
        } , function() { //On hover out...
            $(this).find("span").stop().animate({
                marginTop: "0" //Move the span back to its original state (0px)
            }, 250);
        });

    结果如下图所示:

    高否?富否?帅否? 否? 滚去学习!
  • 相关阅读:
    高精度
    eps取值
    QtCreator常用快捷键
    C++11 麻辣烫
    谈一些关于华为鸿蒙的看法
    Termux新手基础+进阶学习笔记(间断更新)
    分享互联网2021年最新Java面试题汇总整理-附详细答案解析
    2021年面试,整理全网初、中、高级常见Java面试题附答案
    JS中使用map
    springboot整合MongoDB4.0多数据源实现事务
  • 原文地址:https://www.cnblogs.com/baixc/p/3415100.html
Copyright © 2020-2023  润新知