前端小卡片效果(附源码)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Akshar&family=Koulen&family=Pacifico&family=Roboto:wght@100;300&family=Tapestry&family=Ubuntu&display=swap');
body {
background: black;
height: 100vh;
overflow: hidden;
align-items: center;
display: flex;
justify-content: center;
}
.profile {
aspect-ratio: 7 / 8;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 5px;
width: 300px;
}
.center {
align-items: center;
display: flex;
justify-content: center;
flex-wrap: wrap;
height: 300px;
padding: 20px;
}
.white {
height: 72%;
position: relative;
aspect-ratio: 1;
border: 4px solid white;
border-radius: 50%;
}
.img {
height: 200px;
width: 200px;
border-radius: 50%;
margin: 8px;
object-fit: cover;
}
.name {
font-family: 'Pacifico', cursive;
font-size: 2em;
color: white;
margin: 0px;
text-align: center;
}
</style>
</head>
<body>
<div class="profile">
<div class="center">
<div class="white">
<img class="img"
src="https://images.pexels.com/photos/9818341/pexels-photo-9818341.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" />
</div>
<h3 class="name">Patricia</h3>
</div>
</div>
</body>
</html>
页:
[1]