Ответы пользователя по тегу JavaScript
  • Как можно реализовать плавное появление текста на картинке?

    Sprime
    @Sprime
    HTML-верстальщик
    HTML:
    <div class="container">
        <div class="block">
            <img src="http://groundctrl.s3.amazonaws.com/clients/justin-timberlake/media/03/11/feature_images/assets/original.VdBDxo14evIQMNj14uZiR-N623UIA0uve9ZaHPbqpGs.jpg" alt="">
            <a href="#"><span>Some text</span></a>
        </div>
        
        <div class="block">
            <img src="http://groundctrl.s3.amazonaws.com/clients/justin-timberlake/media/01/06/feature_images/assets/original.rcb9s2aCheVeAzuiWpf1nR_qLoDvawEYuRuXApi6tcI.jpg" alt="">
            <a href="#"><span>Some text</span></a>
        </div>
            
        <div class="block">
            <img src="http://groundctrl.s3.amazonaws.com/clients/justin-timberlake/site/home/JoinTheTNKids.jpg" alt="">
            <a href="#"><span>Some text</span></a>
        </div>
            
        <div class="block">
            <img src="http://groundctrl.s3.amazonaws.com/clients/justin-timberlake/site/home/tourPhotos.jpg" alt="">
            <a href="#"><span>Some text</span></a>
        </div>
    </div>

    CSS:
    .container:before,
    .container:after {
        clear: both;
        content: '';
        line-height: 0;
        display: block;
    }
    
    .block {
        width: 25%;
        float: left;
        background: #aaa;
        position: relative;
    }
    .block img {
        display: block;
        max-width: 100%;
    }
    .block a {
        top: 0;
        left: 0;
        opacity: 0;
        color: #fff;
        width: 100%;
        height: 100%;
        display: block;
        text-align: center;
        visibility: hidden;
        position: absolute;
        text-decoration: none;
        background: rgba(0,0,0,.5);
        -webkit-transition: all 0.2s;
                transition: all 0.2s;
    }
    .block a span {
        color: #fff;
        padding: 3px 5px;
        position: absolute;
        bottom: 0; right: 0;
        background: rgba(143, 0, 0, 1);
    }
    .block:hover a {
        opacity: 1;
        visibility: visible;
    }

    jsfiddle.net
    Ответ написан
    Комментировать