" statement to set the background music; 2. Use the "" statement to set the background music; 3. Use The "" statement sets background music."/> " statement to set the background music; 2. Use the "" statement to set the background music; 3. Use The "" statement sets background music.">

Home  >  Article  >  Web Front-end  >  How to set background music in html

How to set background music in html

青灯夜游
青灯夜游Original
2021-05-14 16:50:4529451browse

设置方法:1、使用“834f30dcc955f1fa93b1ac1d93a4fd1081d2bc32cafa2076a27f10cdd878d0ab”语句设置背景音乐;2、使用“6ef5ad1089fe4ca9ff55b7537b11f362”语句设置背景音乐;3、使用“e7f2edec70d7f07984d8ede5491c6c4f”语句设置背景音乐。

How to set background music in html

本教程操作环境:windows7系统、HTML5版、Dell G3电脑。

方法一:

在源代码中编写以下几句代码将能实现在HTML网页内添加背景音乐;

	<audio autoplay="autoplay" controls="controls" loop="loop" preload="auto"
            	src="http://demo.mimvp.com/html5/take_you_fly.mp3">
      		你的浏览器版本太低,不支持audio标签
	</audio>

说明:

1、使用autoplay="autoplay",则背景音乐将在音网页打开后就自动马上播放。

2、使用controls="controls",则为了在页面内显示显示控件,如播放按钮。

3、使用"loop="loop",则是为了是背景音乐重复播放。

4、使用preload="auto",则音频在页面加载的同时进行加载,并预备播放。

5、使用src="",即是在""内加入背景音乐的保存路径,如:src="web网页制作\03.mp3"。

注:若是想播放按钮隐藏,则使用以下语句:

    直接使用css 的display控制audio标签的显示和隐藏:

<style type="text/css">
     audio{
             display: none;
         }
</style>

方法二:

在93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1中的title标签之下添加以下这行代码

<embed src="web网页制作\03.mp3" hidden="true" autostart="true" loop="true">

说明:

1、src="",在""内添加你音乐的保存路径。

2、使用hidden="true"表示隐藏音乐播放按钮,相反使用hidden="false"表示开启音乐播放按钮。

3、使用autostart="true" 表示是打开网页加载完后自动播放。

4、使用loop="true"表示 循环播放 如仅想播放一次则为:loop="false"

方法三:

在HTML中敲写以下代码:

<bgsound src="音乐保存的绝对路径" autostart=true loop=infinite>

说明:1、使用autostart=true,表示音乐在网页加载同时加载音乐,打开网页时音乐自动播放。

推荐教程:《html视频教程

The above is the detailed content of How to set background music in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to add js to htmlNext article:How to add js to html