使用 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>
廣告