使用 CSS 設定圖片上的按鈕
你可以嘗試執行以下程式碼在圖片上設定按鈕
示例
<!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://tutorialspoint.tw/videotutorials/images/current_affairs_home.jpg" alt = "Current Affairs">
<button class = "btn">Button</button>
</div>
</body>
</html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
安卓
Python
C 語言
C++
C#
MongoDB
MySQL
Javascript
PHP