CSS3-炫酷网站带缩略图的文章卡片UI界面设计

这是一款效果非常炫酷的网站列表页文章卡片UI界面设计效果。该文章卡片中包含了文章的缩略图、标题、文章简介等内容。文章的简介默认是不可见的,当鼠标滑过卡片时,缩略图被缩小,文章简介内容随之滑动显示出来。

使用方法

HTML结构

该文章卡片的HTML结构如下:

<div class='column'>
  <div class='post-module'>
    <!--缩略图-->
    <div class='thumbnail'>
      <img src='img/demo.jpg'>
    </div>
    <div class='post-content'>
      <div class='category'>文章类别</div>
      <h1 class='title'>文章标题</h1>
      <h2 class='sub_title'>文章子标题</h2>
      <p class='description'>文章简介......</p>
      <div class='post-meta'>
        <span class='timestamp'>
          <i class='fa fa-clock-o'></i>
          6 分钟前
        </span>
        <span class='comments'>
          <i class='fa fa-comments'></i>
          <a href='#'>39 回复</a>
        </span>
      </div>
    </div>
  </div>
</div>              
CSS样式

在鼠标滑过卡片的时候,卡片容器的阴影会发生动画效果,阴影被放大,就像卡片要脱离出屏幕一样。

.post-module {
  position: relative;
  z-index: 1;
  display: block;
  background: #ffffff;
  min-width: 270px;
  height: 470px;
  -webkit-box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
  -moz-box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
  box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
  -webkit-transition: all 0.3s linear 0s;
  -moz-transition: all 0.3s linear 0s;
  -ms-transition: all 0.3s linear 0s;
  -o-transition: all 0.3s linear 0s;
  transition: all 0.3s linear 0s;
}
.post-module:hover,
.hover {
  -webkit-box-shadow: 0px 1px 35px 0px rgba(0, 0, 0, 0.3);
  -moz-box-shadow: 0px 1px 35px 0px rgba(0, 0, 0, 0.3);
  box-shadow: 0px 1px 35px 0px rgba(0, 0, 0, 0.3);
}                

然后在鼠标滑过卡片的时候,缩略图被放大1.1倍,透明度降低为0.6。

.post-module .thumbnail img {
  display: block;
  width: 120%;
  -webkit-transition: all 0.3s linear 0s;
  -moz-transition: all 0.3s linear 0s;
  -ms-transition: all 0.3s linear 0s;
  -o-transition: all 0.3s linear 0s;
  transition: all 0.3s linear 0s;
}
.post-module:hover .thumbnail img,
.hover .thumbnail img {
  -webkit-transform: scale(1.1);
  -moz-transform: scale(1.1);
  transform: scale(1.1);
  opacity: .6;
}                

默认的文章简介部分p.description设置为display: none;,是不可见的。后面在鼠标滑过卡片的时候,会使用一些jQuery代码来切换它的可见性。

.post-module .post-content .description {
  display: none;
  color: #666666;
  font-size: 14px;
  line-height: 1.8em;
}                
JavaScript

为了切换文章简介部分的可见性和高度,这里使用了jQuery的animate()方法。在鼠标滑过卡片的时候,代码从.post-module包装集中查找.description元素,并在300毫秒的时间内切换它的高度和可见性。

$(window).load(function () {
    $('.post-module').hover(function () {
        $(this).find('.description').stop().animate({
            height: 'toggle',
            opacity: 'toggle'
        }, 300);
    });
});                

在线预览 网盘下载

郑重声明:

1 本资源来源于互联网,资源的版权归资源原作者所持有,受《中华人民共和国著作权法》等相关法律保护。

2 由于无法和原作者取得联系,所以上传的部分资源无法先通过原作者的同意就分享给大家了,如本资源侵犯了您(原作者)的权益,请联系我们(微信号 xiaohaimei1989),我们会立马删除您的资源,并向您表达诚挚的歉意!

3 本站是一个公益型网站,分享资源的目的在于传播知识,分享知识,收取一点点打赏的辛苦费是用于网站的日常运营开支,并非用于商业用途。

4 本站资源只提供学习和参考研究使用,使用过后请在第一时间内删除。本站不承担资源被单位或个人商用带来的法律责任。

发表评论