如何获得这种悬停CSS3效果?

时间:2014-10-25 01:25:44

标签: html css css3

我有以下HTML:

<div class="item">
    <img src="images/gallery/woman-1.jpg" alt="" width="100%" >
    <div class="content">
        <h3>A blog title.</h3>
    </div><!-- /.content -->
</div>

以下CSS:

.gallery {
    .item {
        width: 33%;
        height: auto;
        float: left;
    }
}

我想得到这个&#34; Creative Zoe&#34;对此处项目的影响:

http://tympanus.net/Development/HoverEffectIdeas/

我已经下载了源代码并试图申请这些项目,但是当我这样做时,没有任何作用。我不确定我做错了什么。这是我的尝试:

https://dl.dropboxusercontent.com/u/54191672/theme/index.html

我很难过,我的项目真的很喜欢这种效果。我怎么能正确地做到这一点?

1 个答案:

答案 0 :(得分:2)

&#13;
&#13;
figure.effect-zoe figcaption {
  top: auto;
  bottom: 0;
  padding: 1em;
  height: 3.75em;
  background: #fff;
  color: #3c4a50;
  -webkit-transition: -webkit-transform 0.35s;
  transition: transform 0.35s;
  -webkit-transform: translate3d(0, 100%, 0);
  transform: translate3d(0, 100%, 0);
}
figure.effect-zoe h2 {
  float: left;
}
figure.effect-zoe figcaption > span {
  float: right;
}
figure.effect-zoe p {
  position: absolute;
  bottom: 8em;
  padding: 2em;
  color: #fff;
  text-transform: none;
  font-size: 90%;
  opacity: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transition: opacity 0.35s;
  transition: opacity 0.35s;
}
figure.effect-zoe h2,
figure.effect-zoe figcaption > span {
  -webkit-transition: -webkit-transform 0.35s;
  transition: transform 0.35s;
  -webkit-transform: translate3d(0, 200%, 0);
  transform: translate3d(0, 200%, 0);
}
figure.effect-zoe figcaption > span::before {
  display: inline-block;
  padding: 8px 10px;
  font-family: 'feathericons';
  speak: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.icon-eye::before {
  content: '\e000';
}
.icon-paper-clip::before {
  content: '\e001';
}
.icon-heart::before {
  content: '\e024';
}
figure.effect-zoe h2 {
  display: inline-block;
}
figure.effect-zoe:hover p {
  opacity: 1;
}
figure.effect-zoe:hover figcaption,
figure.effect-zoe:hover h2,
figure.effect-zoe:hover figcaption > span {
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}
figure.effect-zoe:hover h2 {
  -webkit-transition-delay: 0.05s;
  transition-delay: 0.05s;
}
figure.effect-zoe:hover figcaption > span:nth-child(4) {
  -webkit-transition-delay: 0.1s;
  transition-delay: 0.1s;
}
figure.effect-zoe:hover figcaption > span:nth-child(3) {
  -webkit-transition-delay: 0.15s;
  transition-delay: 0.15s;
}
figure.effect-zoe:hover figcaption > span:nth-child(2) {
  -webkit-transition-delay: 0.2s;
  transition-delay: 0.2s;
}
&#13;
<figure class="effect-zoe">
  <img src="img/14.jpg" alt="img14">
  <figcaption>
    <h2>Creative <span>Zoe</span></h2>
    <span class="icon-heart"></span>
    <span class="icon-eye"></span>
    <span class="icon-paper-clip"></span>
    <p>Zoe never had the patience of her sisters. She deliberately punched the bear in his face.</p>
    <a href="#">View more</a>
  </figcaption>
</figure>
&#13;
&#13;
&#13;

您似乎错过了用于触发效果的html上的类。

<figure class="effect-zoe">
                    <img src="img/14.jpg" alt="img14">
                    <figcaption>
                        <h2>Creative <span>Zoe</span></h2>
                        <span class="icon-heart"></span>
                        <span class="icon-eye"></span>
                        <span class="icon-paper-clip"></span>
                        <p>Zoe never had the patience of her sisters. She deliberately punched the bear in his face.</p>
                        <a href="#">View more</a>
                    </figcaption>           
                </figure>

他们也有很多你似乎没有的CSS

/*---------------*/
/***** Zoe *****/
/*---------------*/

figure.effect-zoe figcaption {
    top: auto;
    bottom: 0;
    padding: 1em;
    height: 3.75em;
    background: #fff;
    color: #3c4a50;
    -webkit-transition: -webkit-transform 0.35s;
    transition: transform 0.35s;
    -webkit-transform: translate3d(0,100%,0);
    transform: translate3d(0,100%,0);
}

figure.effect-zoe h2 {
    float: left;
}

figure.effect-zoe figcaption > span {
    float: right;
}

figure.effect-zoe p {
    position: absolute;
    bottom: 8em;
    padding: 2em;
    color: #fff;
    text-transform: none;
    font-size: 90%;
    opacity: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transition: opacity 0.35s;
    transition: opacity 0.35s;
}

figure.effect-zoe h2,
figure.effect-zoe figcaption > span {
    -webkit-transition: -webkit-transform 0.35s;
    transition: transform 0.35s;
    -webkit-transform: translate3d(0,200%,0);
    transform: translate3d(0,200%,0);
}

figure.effect-zoe figcaption > span::before {
    display: inline-block;
    padding: 8px 10px;
    font-family: 'feathericons';
    speak: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.icon-eye::before {
    content: '\e000';
}

.icon-paper-clip::before {
    content: '\e001';
}

.icon-heart::before {
    content: '\e024';
}

figure.effect-zoe h2 {
    display: inline-block;
}

figure.effect-zoe:hover p {
    opacity: 1;
}

figure.effect-zoe:hover figcaption,
figure.effect-zoe:hover h2,
figure.effect-zoe:hover figcaption > span {
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
}

figure.effect-zoe:hover h2 {
    -webkit-transition-delay: 0.05s;
    transition-delay: 0.05s;
}

figure.effect-zoe:hover figcaption > span:nth-child(4) {
    -webkit-transition-delay: 0.1s;
    transition-delay: 0.1s;
}

figure.effect-zoe:hover figcaption > span:nth-child(3) {
    -webkit-transition-delay: 0.15s;
    transition-delay: 0.15s;
}

figure.effect-zoe:hover figcaption > span:nth-child(2) {
    -webkit-transition-delay: 0.2s;
    transition-delay: 0.2s;
}