如何在你的網頁中新增背景音樂?
若要給網頁新增背景音樂,使用 <embed>…</embed> 元素。同時,使用自動播放屬性。這會在網頁載入時在後臺播放音樂。
設定 width 和 height 以使播放器隱藏在網頁上。loop 屬性用來指定音訊是否會重新開始。將音樂檔案新增到伺服器,並在 src 屬性中提及連結。

示例
你可以嘗試執行以下程式碼,給網頁新增背景音樂
<!DOCTYPE html> <html> <head> <title>HTML background music</title> </head> <body> <p>The music is running in the background.</p> <p>(Song: Kalimba which is provided as a Sample Music in Windows)</p> <embed src="/html/Kalimba.mp3" loop="true" autostart="true" width="2" height="0"> </body> </html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP