treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Description on image-hover

  • Hello.

    I'm making a website, and I'm sort of a newbie. I'm making this gallery, and I'd like to have a fancy way of choosing some of the albums. What I want is that when a user hovers over an image, a black (almost) transparent box will appear on the image with a description in a white font. I was thinking that this box would slide up, and perhaps this could be done using jQuery. Is this possible to make?

    Thanks in advance.
  • ok something like this
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; 
    <html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>some</title>

    <style type="text/css">
    body {
    font: 10px normal Verdana, Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    background: #000;
    }

    .vertalign {
    height: 481px;
    width: 598px;
    margin: -240px 0 0 -299px;
    top: 50%;
    left: 50%;
    position: absolute;
    }



    .imgteaser {
    margin: 0;
    overflow: hidden;
    float: left;
    position: relative;
    }
    .imgteaser a {
    text-decoration: none;
    float: left;
    }
    .imgteaser a:hover {
    cursor: pointer;
    }
    .imgteaser a img {
    float: left;
    margin: 0;
    border: none;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    }
    .imgteaser a .more {
    position: absolute;
    right: 20px;
    bottom: 20px;
    font-size: 1.2em;
    color: #fff;
    background: #000;
    padding: 5px 10px;
    filter:alpha(opacity=65);
    opacity:.65;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=65)"; /*--IE 8 Transparency--*/
    }
    .imgteaser a .desc { display: none; }
    .imgteaser a:hover .more { visibility: hidden;}
    .imgteaser a:hover .desc{
    display: block;
    font-size: 1.2em;
    padding: 10px 0;
    background: #111;
    filter:alpha(opacity=75);
    opacity:.75;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=75)"; /*--IE 8 Transparency--*/
    color: #fff;
    position: absolute;
    bottom: 11px;
    left: 11px;
    padding: 10px;
    margin: 0;
    width: 566px;
    border-top: 1px solid #999;
    }
    .imgteaser a:hover .desc strong {
    display: block;
    margin-bottom: 5px;
    font-size:1.5em;
    }
    </style>

    </head>

    <body>

    <div class="vertalign">

    <div class="imgteaser">
    <a href="#">
    <img src="http://www.coolhunting.com/2010/08/bugatti-veyron-super-sport.jpg&quot; alt="Daim Graffiti" />
    <span class="more">&raquo; Learn More</span>
    <span class="desc">
    <strong>Veyron Super sport</strong>
    your description on the image
    </span>
    </a>
    </div>

    </div>

    </body>
    </html>


    this wasn't coded by me but i remembered having this code when i was trying to tho that and only with css...
  • Thank you, sir. It works like a charm. :)