用css3实现图片悬停效果特效cid1048-代码设计


html and css

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>interactive hover effect</title>
  6. <style>
  7. @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,200,300,600,700,900);
  8. body {
  9. background: #dce1df;
  10. color: #4f585e;
  11. font-family: 'Source Sans Pro', sans-serif;
  12. text-rendering: optimizeLegibility;
  13. }
  14. a.btn {
  15. background: #0096a0;
  16. border-radius: 4px;
  17. box-shadow: 0 2px 0px 0 rgba(0, 0, 0, 0.25);
  18. color: #ffffff;
  19. display: inline-block;
  20. padding: 6px 30px 8px;
  21. position: relative;
  22. text-decoration: none;
  23. transition: all 0.1s 0s ease-out;
  24. }
  25. .no-touch a.btn:hover {
  26. background: #00a2ad;
  27. box-shadow: 0px 8px 2px 0 rgba(0, 0, 0, 0.075);
  28. transform: translateY(-2px);
  29. transition: all 0.25s 0s ease-out;
  30. }
  31. .no-touch a.btn:active,
  32. a.btn:active {
  33. background: #008a93;
  34. box-shadow: 0 1px 0px 0 rgba(255, 255, 255, 0.25);
  35. transform: translate3d(0, 1px, 0);
  36. transition: all 0.025s 0s ease-out;
  37. }
  38. div.cards {
  39. margin: 80px auto;
  40. max-width: 960px;
  41. text-align: center;
  42. }
  43. div.card {
  44. background: #ffffff;
  45. display: inline-block;
  46. margin: 8px;
  47. max-width: 300px;
  48. perspective: 1000;
  49. position: relative;
  50. text-align: left;
  51. transition: all 0.3s 0s ease-in;
  52. z-index: 1;
  53. }
  54. div.card img {
  55. max-width: 300px;
  56. }
  57. div.card div.card-title {
  58. background: #ffffff;
  59. padding: 6px 15px 10px;
  60. position: relative;
  61. z-index: 0;
  62. }
  63. div.card div.card-title a.toggle-info {
  64. border-radius: 32px;
  65. height: 32px;
  66. padding: 0;
  67. position: absolute;
  68. right: 15px;
  69. top: 10px;
  70. width: 32px;
  71. }
  72. div.card div.card-title a.toggle-info span {
  73. background: #ffffff;
  74. display: block;
  75. height: 2px;
  76. position: absolute;
  77. top: 16px;
  78. transition: all 0.15s 0s ease-out;
  79. width: 12px;
  80. }
  81. div.card div.card-title a.toggle-info span.left {
  82. right: 14px;
  83. transform: rotate(45deg);
  84. }
  85. div.card div.card-title a.toggle-info span.right {
  86. left: 14px;
  87. transform: rotate(-45deg);
  88. }
  89. div.card div.card-title h2 {
  90. font-size: 24px;
  91. font-weight: 700;
  92. letter-spacing: -0.05em;
  93. margin: 0;
  94. padding: 0;
  95. }
  96. div.card div.card-title h2 small {
  97. display: block;
  98. font-size: 18px;
  99. font-weight: 600;
  100. letter-spacing: -0.025em;
  101. }
  102. div.card div.card-description {
  103. padding: 0 15px 10px;
  104. position: relative;
  105. font-size: 14px;
  106. }
  107. div.card div.card-actions {
  108. box-shadow: 0 2px 0px 0 rgba(0, 0, 0, 0.075);
  109. padding: 10px 15px 20px;
  110. text-align: center;
  111. }
  112. div.card div.card-flap {
  113. background: #d9d9d9;
  114. position: absolute;
  115. width: 100%;
  116. transform-origin: top;
  117. transform: rotateX(-90deg);
  118. }
  119. div.card div.flap1 {
  120. transition: all 0.3s 0.3s ease-out;
  121. z-index: -1;
  122. }
  123. div.card div.flap2 {
  124. transition: all 0.3s 0s ease-out;
  125. z-index: -2;
  126. }
  127. div.cards.showing div.card {
  128. cursor: pointer;
  129. opacity: 0.6;
  130. transform: scale(0.88);
  131. }
  132. .no-touch div.cards.showing div.card:hover {
  133. opacity: 0.94;
  134. transform: scale(0.92);
  135. }
  136. div.card.show {
  137. opacity: 1 !important;
  138. transform: scale(1) !important;
  139. }
  140. div.card.show div.card-title a.toggle-info {
  141. background: #ff6666 !important;
  142. }
  143. div.card.show div.card-title a.toggle-info span {
  144. top: 15px;
  145. }
  146. div.card.show div.card-title a.toggle-info span.left {
  147. right: 10px;
  148. }
  149. div.card.show div.card-title a.toggle-info span.right {
  150. left: 10px;
  151. }
  152. div.card.show div.card-flap {
  153. background: #ffffff;
  154. transform: rotateX(0deg);
  155. }
  156. div.card.show div.flap1 {
  157. transition: all 0.3s 0s ease-out;
  158. }
  159. div.card.show div.flap2 {
  160. transition: all 0.3s 0.2s ease-out;
  161. }
  162. </style>
  163. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js">
  164. </script>
  165. </head>
  166. <body>
  167. <div class="cards">
  168. <div class="card">
  169. <img class="card-image" src="file/one.jpg" alt="">
  170. <div class="card-title">
  171. <a href="" class="toggle-info btn">
  172. <span class="left"></span>
  173. <span class="right"></span>
  174. </a>
  175. <h2>
  176. HOVER EFFECT
  177. <small>INTERACTIVE HOVER EFFECT</small>
  178. </h2>
  179. </div>
  180. <div class="card-flap flap1">
  181. <div class="card-description">
  182. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
  183. </div>
  184. <div class="card-flap flap2">
  185. <div class="card-actions">
  186. <a href="" class="btn">READ MORE</a>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. <div class="card">
  192. <img class="card-image" src="file/two.jpg" alt="">
  193. <div class="card-title">
  194. <a href="" class="toggle-info btn">
  195. <span class="left"></span>
  196. <span class="right"></span>
  197. </a>
  198. <h2>
  199. INTERACTIVE DESIGN
  200. <small>INTERACTIVE HOVER EFFECT</small>
  201. </h2>
  202. </div>
  203. <div class="card-flap flap1">
  204. <div class="card-description">
  205. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
  206. </div>
  207. <div class="card-flap flap2">
  208. <div class="card-actions">
  209. <a href="" class="btn">READ MORE</a>
  210. </div>
  211. </div>
  212. </div>
  213. </div>
  214. <div class="card">
  215. <img class="card-image" src="file/five.jpg" alt="">
  216. <div class="card-title">
  217. <a href="" class="toggle-info btn">
  218. <span class="left"></span>
  219. <span class="right"></span>
  220. </a>
  221. <h2>
  222. HOVER EFFECT
  223. <small>INTERACTIVE HOVER EFFECT</small>
  224. </h2>
  225. </div>
  226. <div class="card-flap flap1">
  227. <div class="card-description">
  228. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
  229. </div>
  230. <div class="card-flap flap2">
  231. <div class="card-actions">
  232. <a href="" class="btn">READ MORE</a>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. <div class="card">
  238. <img class="card-image" src="file/four.jpg" alt="">
  239. <div class="card-title">
  240. <a href="" class="toggle-info btn">
  241. <span class="left"></span>
  242. <span class="right"></span>
  243. </a>
  244. <h2>
  245. HOVER EFFECT
  246. <small>INTERACTIVE HOVER EFFECT</small>
  247. </h2>
  248. </div>
  249. <div class="card-flap flap1">
  250. <div class="card-description">
  251. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
  252. </div>
  253. <div class="card-flap flap2">
  254. <div class="card-actions">
  255. <a href="" class="btn">READ MORE</a>
  256. </div>
  257. </div>
  258. </div>
  259. </div>
  260. <div class="card">
  261. <img class="card-image" src="file/six.jpg" alt="">
  262. <div class="card-title">
  263. <a href="" class="toggle-info btn">
  264. <span class="left"></span>
  265. <span class="right"></span>
  266. </a>
  267. <h2>
  268. HOVER EFFECT
  269. <small>INTERACTIVE HOVER EFFECT</small>
  270. </h2>
  271. </div>
  272. <div class="card-flap flap1">
  273. <div class="card-description">
  274. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
  275. </div>
  276. <div class="card-flap flap2">
  277. <div class="card-actions">
  278. <a href="" class="btn">READ MORE</a>
  279. </div>
  280. </div>
  281. </div>
  282. </div>
  283. <div class="card">
  284. <img class="card-image" src="file/seven.jpg" alt="">
  285. <div class="card-title">
  286. <a href="" class="toggle-info btn">
  287. <span class="left"></span>
  288. <span class="right"></span>
  289. </a>
  290. <h2>
  291. HOVER EFFECT
  292. <small>INTERACTIVE HOVER EFFECT</small>
  293. </h2>
  294. </div>
  295. <div class="card-flap flap1">
  296. <div class="card-description">
  297. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
  298. </div>
  299. <div class="card-flap flap2">
  300. <div class="card-actions">
  301. <a href="" class="btn">READ MORE</a>
  302. </div>
  303. </div>
  304. </div>
  305. </div>
  306. </div>
  307. <script>
  308. $(document).ready(function(){
  309. var zindex = 10;
  310. $("div.card").click(function(e){
  311. e.preventDefault();
  312. var isShowing = false;
  313. if ($(this).hasClass("show")) {
  314. isShowing = true
  315. }
  316. if ($("div.cards").hasClass("showing")) {
  317. // a card is already in view
  318. $("div.card.show")
  319. .removeClass("show");
  320. if (isShowing) {
  321. // this card was showing - reset the grid
  322. $("div.cards")
  323. .removeClass("showing");
  324. } else {
  325. // this card isn't showing - get in with it
  326. $(this)
  327. .css({zIndex: zindex})
  328. .addClass("show");
  329. }
  330. zindex++;
  331. } else {
  332. // no cards in view
  333. $("div.cards")
  334. .addClass("showing");
  335. $(this)
  336. .css({zIndex:zindex})
  337. .addClass("show");
  338. zindex++;
  339. }
  340. });
  341. });
  342. </script>
  343. </body>
  344. </html>
 <!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <title>interactive hover effect</title>
     
     <style>
      @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,200,300,600,700,900);
body {
  background: #dce1df;
  color: #4f585e;
  font-family: 'Source Sans Pro', sans-serif;
  text-rendering: optimizeLegibility;
}
a.btn {
  background: #0096a0;
  border-radius: 4px;
  box-shadow: 0 2px 0px 0 rgba(0, 0, 0, 0.25);
  color: #ffffff;
  display: inline-block;
  padding: 6px 30px 8px;
  position: relative;
  text-decoration: none;
  transition: all 0.1s 0s ease-out;
}
.no-touch a.btn:hover {
  background: #00a2ad;
  box-shadow: 0px 8px 2px 0 rgba(0, 0, 0, 0.075);
  transform: translateY(-2px);
  transition: all 0.25s 0s ease-out;
}
.no-touch a.btn:active,
a.btn:active {
  background: #008a93;
  box-shadow: 0 1px 0px 0 rgba(255, 255, 255, 0.25);
  transform: translate3d(0, 1px, 0);
  transition: all 0.025s 0s ease-out;
}
div.cards {
  margin: 80px auto;
  max-width: 960px;
  text-align: center;
}
div.card {
  background: #ffffff;
  display: inline-block;
  margin: 8px;
  max-width: 300px;
  perspective: 1000;
  position: relative;
  text-align: left;
  transition: all 0.3s 0s ease-in;
  z-index: 1;
}
div.card img {
  max-width: 300px;
}
div.card div.card-title {
  background: #ffffff;
  padding: 6px 15px 10px;
  position: relative;
  z-index: 0;
}
div.card div.card-title a.toggle-info {
  border-radius: 32px;
  height: 32px;
  padding: 0;
  position: absolute;
  right: 15px;
  top: 10px;
  width: 32px;
}
div.card div.card-title a.toggle-info span {
  background: #ffffff;
  display: block;
  height: 2px;
  position: absolute;
  top: 16px;
  transition: all 0.15s 0s ease-out;
  width: 12px;
}
div.card div.card-title a.toggle-info span.left {
  right: 14px;
  transform: rotate(45deg);
}
div.card div.card-title a.toggle-info span.right {
  left: 14px;
  transform: rotate(-45deg);
}
div.card div.card-title h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.05em;
  margin: 0;
  padding: 0;
}
div.card div.card-title h2 small {
  display: block;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.025em;
}
div.card div.card-description {
  padding: 0 15px 10px;
  position: relative;
  font-size: 14px;
}
div.card div.card-actions {
  box-shadow: 0 2px 0px 0 rgba(0, 0, 0, 0.075);
  padding: 10px 15px 20px;
  text-align: center;
}
div.card div.card-flap {
  background: #d9d9d9;
  position: absolute;
  width: 100%;
  transform-origin: top;
  transform: rotateX(-90deg);
}
div.card div.flap1 {
  transition: all 0.3s 0.3s ease-out;
  z-index: -1;
}
div.card div.flap2 {
  transition: all 0.3s 0s ease-out;
  z-index: -2;
}
div.cards.showing div.card {
  cursor: pointer;
  opacity: 0.6;
  transform: scale(0.88);
}
.no-touch div.cards.showing div.card:hover {
  opacity: 0.94;
  transform: scale(0.92);
}
div.card.show {
  opacity: 1 !important;
  transform: scale(1) !important;
}
div.card.show div.card-title a.toggle-info {
  background: #ff6666 !important;
}
div.card.show div.card-title a.toggle-info span {
  top: 15px;
}
div.card.show div.card-title a.toggle-info span.left {
  right: 10px;
}
div.card.show div.card-title a.toggle-info span.right {
  left: 10px;
}
div.card.show div.card-flap {
  background: #ffffff;
  transform: rotateX(0deg);
}
div.card.show div.flap1 {
  transition: all 0.3s 0s ease-out;
}
div.card.show div.flap2 {
  transition: all 0.3s 0.2s ease-out;
}

     </style>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js">
     </script>
 </head>
 <body>
     
     <div class="cards">
         <div class="card">
             <img class="card-image" src="file/one.jpg" alt="">
             <div class="card-title">
                 <a href="" class="toggle-info btn">
                     <span class="left"></span>
                     <span class="right"></span>
                 </a>
                 <h2>
                  HOVER EFFECT 
                 <small>INTERACTIVE HOVER EFFECT</small>
                 </h2>
             </div>
             
             <div class="card-flap flap1">
                 <div class="card-description">
                     Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
                 </div>
                 <div class="card-flap flap2">
                     <div class="card-actions">
                         <a href="" class="btn">READ MORE</a>
                     </div>
                 </div>
             </div>          
         </div>
         
         
         
          <div class="card">
             <img class="card-image" src="file/two.jpg" alt="">
             <div class="card-title">
                 <a href="" class="toggle-info btn">
                     <span class="left"></span>
                     <span class="right"></span>
                 </a>
                 <h2>
                  INTERACTIVE DESIGN 
                 <small>INTERACTIVE HOVER EFFECT</small>
                 </h2>
             </div>
             
             <div class="card-flap flap1">
                 <div class="card-description">
                     Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
                 </div>
                 <div class="card-flap flap2">
                     <div class="card-actions">
                         <a href="" class="btn">READ MORE</a>
                     </div>
                 </div>
             </div>          
         </div>
         
         
          <div class="card">
             <img class="card-image" src="file/five.jpg" alt="">
             <div class="card-title">
                 <a href="" class="toggle-info btn">
                     <span class="left"></span>
                     <span class="right"></span>
                 </a>
                 <h2>
                  HOVER EFFECT 
                 <small>INTERACTIVE HOVER EFFECT</small>
                 </h2>
             </div>
             
             <div class="card-flap flap1">
                 <div class="card-description">
                     Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
                 </div>
                 <div class="card-flap flap2">
                     <div class="card-actions">
                         <a href="" class="btn">READ MORE</a>
                     </div>
                 </div>
             </div>          
         </div>
         
          <div class="card">
             <img class="card-image" src="file/four.jpg" alt="">
             <div class="card-title">
                 <a href="" class="toggle-info btn">
                     <span class="left"></span>
                     <span class="right"></span>
                 </a>
                 <h2>
                  HOVER EFFECT 
                 <small>INTERACTIVE HOVER EFFECT</small>
                 </h2>
             </div>
             
             <div class="card-flap flap1">
                 <div class="card-description">
                     Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
                 </div>
                 <div class="card-flap flap2">
                     <div class="card-actions">
                         <a href="" class="btn">READ MORE</a>
                     </div>
                 </div>
             </div>          
         </div>
         
          <div class="card">
             <img class="card-image" src="file/six.jpg" alt="">
             <div class="card-title">
                 <a href="" class="toggle-info btn">
                     <span class="left"></span>
                     <span class="right"></span>
                 </a>
                 <h2>
                  HOVER EFFECT 
                 <small>INTERACTIVE HOVER EFFECT</small>
                 </h2>
             </div>
             
             <div class="card-flap flap1">
                 <div class="card-description">
                     Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
                 </div>
                 <div class="card-flap flap2">
                     <div class="card-actions">
                         <a href="" class="btn">READ MORE</a>
                     </div>
                 </div>
             </div>          
         </div>
         
          <div class="card">
             <img class="card-image" src="file/seven.jpg" alt="">
             <div class="card-title">
                 <a href="" class="toggle-info btn">
                     <span class="left"></span>
                     <span class="right"></span>
                 </a>
                 <h2>
                  HOVER EFFECT 
                 <small>INTERACTIVE HOVER EFFECT</small>
                 </h2>
             </div>
             
             <div class="card-flap flap1">
                 <div class="card-description">
                     Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, recusandae!
                 </div>
                 <div class="card-flap flap2">
                     <div class="card-actions">
                         <a href="" class="btn">READ MORE</a>
                     </div>
                 </div>
             </div>          
         </div>
    
     </div>
     <script>
     
     $(document).ready(function(){
  var zindex = 10;
  
  $("div.card").click(function(e){
    e.preventDefault();

    var isShowing = false;

    if ($(this).hasClass("show")) {
      isShowing = true
    }

    if ($("div.cards").hasClass("showing")) {
      // a card is already in view
      $("div.card.show")
        .removeClass("show");

      if (isShowing) {
        // this card was showing - reset the grid
        $("div.cards")
          .removeClass("showing");
      } else {
        // this card isn't showing - get in with it
        $(this)
          .css({zIndex: zindex})
          .addClass("show");

      }

      zindex++;

    } else {
      // no cards in view
      $("div.cards")
        .addClass("showing");
      $(this)
        .css({zIndex:zindex})
        .addClass("show");

      zindex++;
    }
    
  });
});
     
     
     </script>
     
     
 </body>
 </html>

在线演示? 让链接同时具备两种打开方式

获取源码: Hoverrrrr
下载数:346人次, 文件大小: 161.5 KB, 上传日期: 2020年-11 月-25日

公众号回复:gcode  获取解压密码

qrcode_for_gh_6ea2c28a1709_258 (1)

3,888 人查阅

类似文章