<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>我的表白</title> <style> body { background-color: #F7D2D7; font-family: '微软雅黑', sans-serif; } h1 { font-size: 72px; color: #FF69B4; text-align: center; margin-top: 100px; } p { font-size: 36px; color: #000; text-align: center; margin-top: 50px; } button { font-size: 24px; color: #FFF; background-color: #FF69B4; border: none; border-radius: 10px; padding: 20px 40px; margin-top: 50px; cursor: pointer; } </style> </head> <body> <h1>亲爱的XXX:</h1> <p>我想对你说:</p> <p>我喜欢你,喜欢你的一切,从你的外表到内心,从你的习惯到性格。</p> <p>你是我心中最美好的存在,我想一直守护着你。</p> <p>我知道我们之间有一些距离,但我相信,只要我们真心相爱,我们一定能克服一切困难。</p> <p>所以,XXX,你愿意成为我的另一半吗?</p> <button onclick="alert('我也喜欢你,愿意成为你的另一半!')">我愿意</button> </body> </html>请为这个程序添加背景音乐的代码
时间: 2023-11-16 07:30:23 浏览: 43
好的,您可以在 `<body>` 标签中添加一个 `<audio>` 标签,并设置 `autoplay` 属性为自动播放,并将 `loop` 属性设置为循环播放。以下是示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的表白</title>
<style>
body {
background-color: #F7D2D7;
font-family: '微软雅黑', sans-serif;
}
h1 {
font-size: 72px;
color: #FF69B4;
text-align: center;
margin-top: 100px;
}
p {
font-size: 36px;
color: #000;
text-align: center;
margin-top: 50px;
}
button {
font-size: 24px;
color: #FFF;
background-color: #FF69B4;
border: none;
border-radius: 10px;
padding: 20px 40px;
margin-top: 50px;
cursor: pointer;
}
</style>
</head>
<body>
<audio src="background_music.mp3" autoplay loop></audio> <!-- 添加背景音乐 -->
<h1>亲爱的XXX:</h1>
<p>我想对你说:</p>
<p>我喜欢你,喜欢你的一切,从你的外表到内心,从你的习惯到性格。</p>
<p>你是我心中最美好的存在,我想一直守护着你。</p>
<p>我知道我们之间有一些距离,但我相信,只要我们真心相爱,我们一定能克服一切困难。</p>
<p>所以,XXX,你愿意成为我的另一半吗?</p>
<button onclick="alert('我也喜欢你,愿意成为你的另一半!')">我愿意</button>
</body>
</html>
```
请将 `background_music.mp3` 替换为您想要添加的背景音乐文件的路径。