如何在你的网页中添加背景音乐?
若要给网页添加背景音乐,使用 <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