爬行的蜗牛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: golang Linux PHP
查看: 112|回复: 0

HTML+CSS实现“个人资料卡悬停效果”

[复制链接]

134

主题

41

回帖

1031

积分

管理员

积分
1031
发表于 2024-11-23 19:19:42 | 显示全部楼层 |阅读模式
111.gif

这是一个更加简洁的效果,当你将鼠标悬停在个人资料卡上时,卡片中的照片会放大,同时显示出人物的姓名和社交媒体链接。这种设计简约而不失美感,不会让用户感到信息过载。
HTML
  1. <div class="container">
  2.   <div class="card card0">
  3.     <div class="border">
  4.       <h2>Al Pacino</h2>
  5.       <div class="icons">
  6.         <i class="fa fa-codepen" aria-hidden="true"></i>
  7.         <i class="fa fa-instagram" aria-hidden="true"></i>
  8.         <i class="fa fa-dribbble" aria-hidden="true"></i>
  9.         <i class="fa fa-twitter" aria-hidden="true"></i>
  10.         <i class="fa fa-facebook" aria-hidden="true"></i>
  11.       </div>
  12.     </div>
  13.   </div>
  14.   <div class="card card1">
  15.     <div class="border">
  16.       <h2>Ben Stiller</h2>
  17.       <div class="icons">
  18.         <i class="fa fa-codepen" aria-hidden="true"></i>
  19.         <i class="fa fa-instagram" aria-hidden="true"></i>
  20.         <i class="fa fa-dribbble" aria-hidden="true"></i>
  21.         <i class="fa fa-twitter" aria-hidden="true"></i>
  22.         <i class="fa fa-facebook" aria-hidden="true"></i>
  23.       </div>
  24.     </div>
  25.   </div>
  26.   <div class="card card2">
  27.     <div class="border">
  28.       <h2>Patrick Stewart</h2>
  29.       <div class="icons">
  30.         <i class="fa fa-codepen" aria-hidden="true"></i>
  31.         <i class="fa fa-instagram" aria-hidden="true"></i>
  32.         <i class="fa fa-dribbble" aria-hidden="true"></i>
  33.         <i class="fa fa-twitter" aria-hidden="true"></i>
  34.         <i class="fa fa-facebook" aria-hidden="true"></i>
  35.       </div>
  36.     </div>
  37.   </div>
  38. </div>
复制代码
CSS
  1. .container
  2.   height: 100vh
  3.   width: 100vw
  4.   max-height: 800px
  5.   max-width: 1280px
  6.   min-height: 600px
  7.   min-width: 1000px
  8.   display: flex
  9.   justify-content: space-around
  10.   align-items: center
  11.   margin: 0 auto

  12. .border
  13.   height: 369px
  14.   width: 290px
  15.   background: transparent
  16.   border-radius: 10px
  17.   transition: border 1s
  18.   position: relative

  19.   &:hover
  20.     border: 1px solid white

  21. .card
  22.   height: 379px
  23.   width: 300px
  24.   background: grey
  25.   border-radius: 10px
  26.   transition: background 0.8s
  27.   overflow: hidden
  28.   background: black
  29.   box-shadow: 0 70px 63px -60px #000000
  30.   display: flex
  31.   justify-content: center
  32.   align-items: center
  33.   position: relative

  34. .card0
  35.   background: url('https://i.pinimg.com/736x/8f/a0/51/8fa051251f5ac2d0b756027089fbffde--terry-o-neill-al-pacino.jpg') center center no-repeat
  36.   background-size: 300px

  37.   &:hover
  38.     background: url('https://i.pinimg.com/736x/8f/a0/51/8fa051251f5ac2d0b756027089fbffde--terry-o-neill-al-pacino.jpg') left center no-repeat
  39.     background-size: 600px

  40.     h2
  41.       opacity: 1

  42.     .fa
  43.       opacity: 1

  44. .card1
  45.   background: url('https://i.pinimg.com/originals/28/d2/e6/28d2e684e7859a0dd17fbd0cea00f8a9.jpg') center center no-repeat
  46.   background-size: 300px

  47.   &:hover
  48.     background: url('https://i.pinimg.com/originals/28/d2/e6/28d2e684e7859a0dd17fbd0cea00f8a9.jpg') left center no-repeat
  49.     background-size: 600px

  50.     h2
  51.       opacity: 1

  52.     .fa
  53.       opacity: 1

  54. .card2
  55.   background: url('https://i.pinimg.com/originals/ee/85/08/ee850842e68cfcf6e3943c048f45c6d1.jpg') center center no-repeat
  56.   background-size: 300px

  57.   &:hover
  58.     background: url('https://i.pinimg.com/originals/ee/85/08/ee850842e68cfcf6e3943c048f45c6d1.jpg') left center no-repeat
  59.     background-size: 600px

  60.     h2
  61.       opacity: 1

  62.     .fa
  63.       opacity: 1

  64. h2
  65.   font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif
  66.   color: white
  67.   margin: 20px
  68.   opacity: 0
  69.   transition: opacity 1s

  70. .fa
  71.   opacity: 0
  72.   transition: opacity 1s

  73. .icons
  74.   position: absolute
  75.   fill: #fff
  76.   color: #fff
  77.   height: 130px
  78.   top: 226px
  79.   width: 50px
  80.   display: flex
  81.   flex-direction: column
  82.   align-items: center
  83.   justify-content: space-around
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表