使用 CSS 在图片上设置按钮
cssweb developmentfront end technology更新于 2024/8/23 7:40:17
您可以尝试运行以下代码在图片上设置按钮:
示例
<!DOCTYPE html>
<html>
<head>
<style>
.box {
position: relative;
width: 100%;
max-width: 250px;
}
.box img {
width: 100%;
height: auto;
}
.box .btn {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class = "box">
<img src = "https://www.cainiaomax.com/videotutorials/images/current_affairs_home.jpg" alt = "Current Affairs">
<button class = "btn">Button</button>
</div>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

