对于图片自动上下左右居中并带翘边阴影的实现,你可以使用HTML和CSS来完成。以下是一个简单的示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Centered Image with Shadow</title>
<style>
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.image-container {
position: relative;
width: 300px; /* 调整图片容器的宽度 */
height: 300px; /* 调整图片容器的高度 */
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); /* 添加阴影效果 */
}
.image-container img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
object-fit: cover; /* 图片充满容器 */
border-radius: 20px; /* 添加翘边效果 */
}
</style>
</head>
<body>
<div class="image-container">
<img src="your-image-url.jpg" alt="Centered Image">
</div>
</body>
</html>