使用 CSS 將背景影像設定為固定
使用 background-attachment 屬性可將背景圖片顯示為固定。
示例
你可以嘗試執行以下程式碼來實現 background-attachment 屬性 −
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("https://tutorialspoint.tw/videotutorials/images/tutor_connect_home.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: right top;
}
</style>
</head>
<body>
<h1>Background Image</h1>
</body>
</html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP