css图片悬浮淡化显示文字标题效果代码

代码语言:html

所属分类:悬停

代码描述:css图片悬浮淡化显示文字标题效果代码

代码标签: css 图片 悬浮 淡化 显示 文字 标题

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">

  <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet">
<STYLE>
    *,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
  font-family: 'Lato', sans-serif;
}

img {
  max-width: 100%;
}

html, body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #222;
}

main {
    display: flex;
    width: 70%;
    justify-content: space-around;
    gap: 2rem;
}

.card {
    width: 450px;
    height: 500px;
    padding: 2rem 1rem;
    background: #fff;
    position: relative;
    display: flex;
    align-items: flex-end;
    box-shadow: 0px 7px 10px rgba(0,0,0,0.5);
    transition: 0.5s ease;
}

.card:hover {
    transform: translateY(20px);
}

.card:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,176,155,0.5), rgba(150,201,61,1));
    z-index: 2;
    transition: all 0.5s;
    opacity: 0;
}

.card:hover:before {
    opacity: 1;
}

.card > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.card .info {
    position: relative;
    z-index: 3;
    color: #fff;
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.5s;
}

.card:hover .info {
    opacity: 1;
    transform: translateY(0px);
}

.card .info h1 {
    margin: 0;
}

.card .info p {
    letter-spacing: 1px;
    font-size: 15px;
    margin: 8px 0 20px;
}

.card .info .btn {
    text-decoration: none;
    paddi.........完整代码请登录后点击上方下载按钮下载查看

网友评论0