使用 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>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP