CSS教程

css悬停效果

本文主要是介绍css悬停效果,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
* {
    margin: 0;
    padding: 0;
    font-family: "Poppins",sans-serif;
}
body {
    display: flex;
    justify-content: center;
    align-items: center;
    background:rgb(76,79,64);
}
.container {
    position: relative;
    height: 600px;
    width: 1200px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 30px;
    
}
    
.container .card {
    position: relative;
    max-width: 300px;
    height: 300px;
    background: #fff;
    margin: 30px 10px;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 202px rgba(0,0,0,0.5);
    transition: 0.3s ease-in-out;
}
.container .card:hover {
    height: 420px;
    
}
.container .card .imgBx {
    position: relative;
    width: 260px;
    height: 260px;
    top: -60px;
    left: 20px;
    z-index: 1;
    box-shadow:0 5px rgba(0,0,0,0.2) ;
}
.container .card .imgBx img {
    max-width: 100%;
    border-radius: 4px;
}
.container .card .content {
    position: relative;
    margin-top:-140px ;
    padding: 10px 15px;
    text-align: center;
    color: #111;
    visibility: hidden;
    opacity: 0;
    transition: 0.3s ease-in-out;
}
.container .card:hover .content {
    visibility: visible;
    opacity: 1;
    margin-top: 35px;
    transition-delay: 0.3s;
}

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="./插画/index/1.css"/>
	</head>
	<body>
	<div class="container">		
		<div class="card">
			<div class="imgBx">
				<img src="插画/插画/006vqr6Rgy1gf5q2slnkej34gr6beqvb.jpg" >
			</div>
			<div class="content">
				<h2>Card One</h2>
				<p>Remember what should be remembered,
				 and forget what should be forgotten.
				 Alter what is changeable, and accept what is unchangeable.</p>
			</div>
		</div>
		<div class="card">
			<div class="imgBx">
				<img src="./插画/插画/006vqr6Rgy1gf21ofcasqj34gr6benpi.jpg" >
			</div>
			<div class="content">
				<h2>Card Two</h2>
				<p>Remember what should be remembered,
				 and forget what should be forgotten.
				 Alter what is changeable, and accept what is unchangeable.</p>
			</div>
		</div>
		<div class="card">
			<div class="imgBx">
				<img src="./插画/插画/006vqr6Rgy1gntr4abpz0j30u016g46e.jpg" >
			</div>
			<div class="content">
				<h2>Card Three</h2>
				<p>Remember what should be remembered,
				 and forget what should be forgotten.
				 Alter what is changeable, and accept what is unchangeable.</p>
			</div>
		</div>
		
	
	</div>
	</body>
</html>

  

 

 

 

这篇关于css悬停效果的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!