zoukankan      html  css  js  c++  java
  • CSS和JQ两种方式实现图片层上显示文字

         先看效果

        HTML 代码:

         <div id="outer" class="outer" style="background: url(IMG/thumb.jpg)">
                 <a href="#" class="now"><span>电 影 钢 的 琴</span> </a>
         </div>

    第一种(纯css代码实现),缺陷:不可以控制显示速度,--speed

    .outer
    {
      height: 280px;
      500px;
      margin: 0px auto;
      position: relative;
    }
    .outer a
    {
      display: none;
      text-decoration: none;
    }
    .outer:hover
    {
      cursor: pointer;
    }
    .outer:hover a.now
    {
      display: block;
    }
    .outer:hover a
    {
       display: block;
       position: absolute;
       bottom: 0;
       left: 0;
       text-decoration:none;
       color:White;
       font-weight:bolder;
       z-index: 10;
        100%;
       height: 9%;
       line-height: 27px;
       background:gray;
      text-align: center;
    }

    第二种(jq方式实现)可以控制speed,效果较好

      html代码:

       <div id="outer" class="outer" style="background: url(IMG/thumb.jpg)">
            <a href="#" class="secondWayCSS"><span>电影钢的琴</span> </a>
      </div>

       css代码:

    .outer
    {
      height: 280px;
      500px;
      margin: 0px auto;
      position: relative;
    }
    .outer:hover
    {
       cursor:pointer;
    }

    .secondWayCSS
    {
       display: none;
       position: absolute;
       bottom: 0;
       left: 0;
      color: red;
      z-index: 10;
      100%;
      height: 9%;
      line-height: 27px;
      background:gray;
      text-align: center;
    }

      jq代码:

    $(function () {
         $("#outer").hover(function () {
           $(this).find("a").slideDown("normal");
          }, function () {
           $(this).find("a").slideUp("normal");
    })
    //实现的方式二;更简单的呀;
    $("#outer").hover(function () {
         $(this).find("a").slideToggle(300);
        })
    })

       

  • 相关阅读:
    利用dns类和WMI规范获取IP及MAC地址
    vs2010编辑器中代码前的虚线问题
    项目发布方法
    HTML5 声明兼容IE的写法 asp.net 狼
    Jquery总结 狼
    IE、FF、Chrome、兼容性文章 狼
    sql游标实现行列转换 狼
    【狼的格言】 狼
    设计模式提升与加强一 狼
    读Head.First设计模式有感 狼
  • 原文地址:https://www.cnblogs.com/mc67/p/4815794.html
Copyright © 2011-2022 走看看