Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Image hover effect

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #166582
    mib70
    Participant

    I’m trying to do an effect that when I pass the mouse over on a picture I want to show a black box that appears closing and I want that only a square in the middle stays where I want to place an icon of a search icon.

    I found a tutorial that explains how to do this, but it explains very lightly.

    I am having a problem because I wanted my picture have width:155px; and height:140px;

    And with this width and height I´m not having sucess with the effect, I already try many alternatives but its not working.

    Can you give me your help?

    This works fine:
    http://jsfiddle.net/ritz/cQL4S/

    But I want with smaller image, and works bad:
    http://jsfiddle.net/ritz/cQL4S/1/

    My html:

    My css:

    .view {
    width: 220px;
    height: 220px;
    margin: 10px;
    float: left;
    border: 5px solid #fff;
    overflow: hidden;
    position: relative;
    text-align: center;
    box-shadow: 0px 0px 5px #aaa;
    cursor: default;
    }
    .view .mask, .view .content {
    width: 220px;
    height: 220px;
    position: absolute;
    overflow: hidden;
    top: 0;
    left: 0;
    }
    .view img {
    display: block;
    position: relative;
    }
    .view a.info {
    background:url(../img/link.png) center no-repeat;
    display: inline-block;
    text-decoration: none;
    padding:0;
    text-indent:-9999px;
    width:20px;
    height:20px;
    }

    .second-effect .mask {
    opacity: 0;
    overflow:visible;
    border:0px solid rgba(0,0,0,0.7);
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;
    box-sizing:border-box;
    -webkit-transition: all 0.4s ease-in-out;
    -moz-transition: all 0.4s ease-in-out;
    -o-transition: all 0.4s ease-in-out;
    -ms-transition: all 0.4s ease-in-out;
    transition: all 0.4s ease-in-out;
    }
    .second-effect a.info {
    position:relative;
    top:-10px;
    opacity:0;
    -moz-transform:scale(0,0);
    -webkit-transform:scale(0,0);
    -o-transform:scale(0,0);
    -ms-transform:scale(0,0);
    transform:scale(0,0);
    -webkit-transition: -webkit-transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
    -moz-transition: -moz-transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
    -o-transition: -o-transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
    -ms-transition: -ms-transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
    transition: transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
    }
    .second-effect:hover .mask {
    opacity: 1;
    border:100px solid rgba(0,0,0,0.7);
    }
    .second-effect:hover a.info {
    opacity:1;
    -moz-transform:scale(1,1);
    -webkit-transform:scale(1,1);
    -o-transform:scale(1,1);
    -ms-transform:scale(1,1);
    transform:scale(1,1);
    -moz-transition-delay:0.3s;
    -webkit-transition-delay:0.3s;
    -o-transition-delay:0.3s;
    -ms-transition-delay:0.3s;
    transition-delay:0.3s;
    }

    #166586
    Gary Pickles
    Participant

    Hi mib70, if you update your css around line 66 to this

    .second-effect:hover .mask {
       opacity: 1;
       border:60px solid rgba(0,0,0,0.7);
       border-bottom: 53px  solid rgba(0,0,0,0.7);
       border-top: 53px  solid rgba(0,0,0,0.7);
    }
    

    i added the top and bottom boarder to make the mask square

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.