SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Montreal, Canada
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Need a jQuery and CSS Ninja !

    Hello Ninja,

    I have problems with my jQuery script on Opera and IE 9.
    If you look at the following code, the title is suppose
    to animate in front of the images. In Opera and IE10,
    the title animates on the right of the image.

    Any ideas will be appreciated!

    Thanks


    =====================================================


    <!DOCTYPE HTML>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>CSS + JQuery</title>

    <style type="text/css">
    * {
    margin:0;
    padding:0;
    }
    body {
    width:400px;
    margin:0 auto;
    text-align:left;
    }
    #box {
    position:relative;
    width:400px;
    height:400px;
    background-color:#fff;
    background-image:url(box.png);
    /*overflow:hidden;*/
    }
    #box .title {
    position:absolute;
    top:400px;
    width:400px;
    height:50px;
    background-color:#000;
    zoom: 1;
    filter: alpha(opacity=75);
    -moz-opacity:0.5;
    -khtml-opacity: 0.5;
    opacity: 0.75;
    }
    #box .title p {
    padding:10px 0 10px 10px;
    font-family:Arial, Helvetica, sans-serif;
    font-size:1em;
    color:#fff;
    }
    a:link, a:active, a:hover, a:visited {
    text-decoration:none;
    }
    img {
    border:0
    }
    </style>

    <script src="../../lib/jquery-1.4.min.js" type="text/javascript" ></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $('img').hide();
    $('#box').hover(function() {
    $('.title').animate({top: '-=50px'}, 200);
    $('img').fadeIn(200);
    }, function() {
    $('.title').animate({top: '+=50px'}, 200);
    $('img').fadeOut(200);
    });
    });
    </script>

    </head>

    <body>
    <a href="#">
    <div id="box">
    <img src="box_h.png">
    <span class="title"><p>This is a title</p></span>
    </div>
    </a>
    </body>
    </html>

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    By simplifying the CSS code right down to its bare bones, I found that you need to add a left declaration to the box title
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Dec 2011
    Location
    Montreal, Canada
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right on! It's exactly what I needed!

    Thanks a lot!

    Jack3000


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •