Css图像悬停有两个标题

时间:2015-02-18 18:19:05

标签: html css image caption

我一直在尝试创建一个图片,在悬停时,标题会从上到下从左到右滑出,从左到右滑出。我已经开始研究两个单独的图像,即:一个图像有顶部标题,一个图像有底部标题;但是我似乎无法同时处理一张图像。此外,我正试图让字幕和图像缩放到容器,这是令人难以置信的。我尝试的另一件事是在顶部幻灯片标题中插入两个div并让它们缩放到大小但我无法继续。 这是我目前的代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>slide caption thingy</title>
    <link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>
<body>
    <div class="wrapper">

        <header>
            <h1 class="main_head">hj</h1>
        </header>

        <hr />

        <div class="container left">
            <img src="images/1.jpg" alt="image" />
            <article class="text css3-3 css3-4">
                <h1><a href="#" class="css3-3 css3-4">space1</a>    </h1>
            </article>
        </div>

        <div class="container right">
            <img src="images/2.jpg" alt="image" />
            <article class="text css3-4">
                <h1><a href="#" class="css3-4">space2</a></h1>
            </article>
        </div>

        <hr />

    </div>

</body>
</html>

CSS

 * {
        margin: 0;
        padding: 0;
    }

    body {
    }

    .wrapper {
        margin: 0 auto;
        width: 960px;
        padding: 30px;
        position: relative;
    }

    .left {
        float: left;
    }

    .right {
        float: right;
    }

    hr {
        border: none;
        width: 100%;
        height: 7px;
        margin: 10px 0 10px 0;
        clear: both;
    }

    a {
        text-shadow: 1px 1px #efefef;
        text-decoration: none;
    }

    b {
        text-shadow: 1px 1px #efefef;
        text-decoration: none;
    }

    header h1.main_head {
        font: 36px/18px Georgia, Arial, sans-serif;
        color: #838383;
        text-shadow: 1px 1px #efefef;
        text-align: center;
        padding: 20px 0 20px 0;
    }


    .container {
        border: 10px solid #fff;
        position: relative;
        overflow: hidden;
        height: 200px;
        -webkit-box-shadow: 0 0 3px #000;
        -moz-box-shadow: 0 0 3px #000;
        box-shadow: 0 0 3px #000;
        -webkit-transition: all .5s ease-out;
        -moz-transition: all .5s ease-out;
        transition: all .5s ease-out;
    }

        .container:hover {
            cursor: pointer;
            -webkit-box-shadow: 0 0 10px #000;
            -moz-box-shadow: 0 0 10px #000;
            box-shadow: 0 0 10px #000;
        }



    .container2 {
        border: 10px solid #fff;
        position: relative;
        overflow: hidden;
        height: 200px;
        -webkit-box-shadow: 0 0 3px #000;
        -moz-box-shadow: 0 0 3px #000;
        box-shadow: 0 0 3px #000;
        -webkit-transition: all .5s ease-out;
        -moz-transition: all .5s ease-out;
        transition: all .5s ease-out;
    }

        .container2:hover {
            cursor: pointer;
            -webkit-box-shadow: 0 0 10px #000;
            -moz-box-shadow: 0 0 10px #000;
            box-shadow: 0 0 10px #000;
        }

    .text {
        background: rgba(0,0,0,0.5);
        color: white;
        font: 14px Georgia,serif;
        height: 80px;
        width: inherit;
        position: absolute;
    }

        .text a {
            color: #fff;
            display: block;
            padding: 15px;
            font-size: 16px;
            font-weight: normal;
            text-shadow: none;
            text-decoration: none;
            width: 400px;
        }



    /* CSS3 Right Effect */
    article.css3-3 {
        right: -400px;
        top: 0;
        -webkit-transition: all .5s ease-out;
        -moz-transition: all .5s ease-out;
        -o-transition: all .5s ease-out;
        transition: all .5s ease-out;
        width: 400px;
    }

    .text a.css3-3 {
        -webkit-transition: all .4s ease-out;
        -moz-transition: all .4s ease-out;
        -o-transition: all .5s ease-out;
        transition: all .4s ease-out;
    }

        .text a.css3-3:hover {
            color: #d0206a;
            text-decoration: none;
        }

    .container:hover article.css3-3 {
        right: 0;
    }

    /* CSS3 Left Effect */
    article.css3-4 {
        left: -400px;
        bottom: 0;
        -webkit-transition: all .5s ease-out;
        -moz-transition: all .5s ease-out;
        -o-transition: all .5s ease-out;
        transition: all .5s ease-out;
        width: 400px;
    }

    .text a.css3-4 {
        -webkit-transition: all .4s ease-out;
        -moz-transition: all .4s ease-out;
        -o-transition: all .5s ease-out;
        transition: all .4s ease-out;
    }

        .text a.css3-4:hover {
            color: #d0206a;
            text-decoration: none;
        }

    .container:hover article.css3-4 {
        left: 0;
    }

1 个答案:

答案 0 :(得分:0)

也许我没有正确理解,但this你在寻找什么?

        <div class="container right">

            <img src="http://placehold.it/350x150" alt="image" />
            <article class="text css3-4">
                    <h1><a href="#" class="css3-4">space1</a></h1>
            </article>
            <article class="text css3-3 css3-4">
                    <h1><a href="#" class="css3-3 css3-4">space2</a>    </h1>
            </article>
        </div>