#include
typedef unsigned char u8;
typedef unsigned int u16;
sbit beepIO=P2^3; //扬声器输出口
u8 m,n;
u8 code T[49][2]={{0,0}, //定义乐曲的音调
{0xF8,0x8B},{0xF8,0xF2},{0xF9,0x5B},{0xF9,0xB7},{0xFA,0x14},{0xFA,0x66},{0xFA,0xB9},{0xFB,0x03},{0xFB,0x4A},{0xFB,0x8F},{0xFB,0xCF},{0xFC,0x0B},
{0xFC,0x43},{0xFC,0x78},{0xFC,0xAB},{0xFC,0xDB},{0xFD,0x08},{0xFD,0x33},{0xFD,0x5B},{0xFD,0x81},{0xFD,0xA5},{0xFD,0xC7},{0xFD,0xE7},{0xFE,0x05},
{0xFE,0x21},{0xFE,0x3C},{0xFE,0x55},{0xFE,0x6D},{0xFE,0x84},{0xFE,0x99},{0xFE,0xAD},{0xFE,0xC0},{0xFE,0x02},{0xFE,0xE3},{0xFE,0xF3},{0xFF,0x02},
{0xFF,0x10},{0xFF,0x1D},{0xFF,0x2A},{0xFF,0x36},{0xFF,0x42},{0xFF,0x4C},{0xFF,0x56},{0xFF,0x60},{0xFF,0x69},{0xFF,0x71},{0xFF,0x79},{0xFF,0x81}
};
u8 code music[][2]={{0,4},{0,4},{0,4},{0,4},{0,8},{0,8},{0,8},{17,4},{21,4},{23,4},{0,4},{0,4},{21,4},{23,4},{0,4},{0,4},{21,4},{23,4},{26,4},{21,4},{23,4},{17,4},{0,4},{17,4},{21,4},{23,4},{0,4},{0,4},{21,4},{23,4},{29,4},{26,4},{28,4},{23,4},{0,4},{17,4},{21,4},{23,4},{0,4},{0,4},{21,4},{23,4},{0,4},{0,4},{21,4},{23,4},{26,4},{21,4},{23,4},{17,4},{21,4}};//定义乐曲的节奏
void delay(u8 p)//延时函数
{ u8 i,j;
for(;p>0;p--)
for(i=181;i>0;i--)
for(j=181;j>0;j--);}
void pause()//延时一个固定时间
{ u8 i,j;
for(i=150;i>0;i--)
for(j=150;j>0;j--);}
void T0_int() interrupt 1 //定时器0中断函数
{ beepIO=!beepIO; //音频输出
TH0=T[m][0]; TL0=T[m][1];} //重新赋初值
void main()
{u8 i=0;
TMOD=0x01; EA=1; ET0=1; //定时器0模式1,开中断
while(1)
{m=music[i][0];n=music[i][1]; //取音调频率
if(m==0x00)
{TR0=0;delay(n);i++;} //为0则延时一定时间,相当于顿音
else if(m==0xFF)
{TR0=0;delay(30);i=0;} //为FF这延时固定时间(停顿)
else if(m==music[i+1][0]) //否则正常旋律
{TR0=1;delay(n);TR0=0;pause();i++;}
else
{TR0=1;delay(n);i++;}
}}
position:absolute;(绝对定位的意思,相比于相对定位)top:50%;left:50%;上面三句就是说,根据浏览器窗口定位,距头部50%,距左边距50%相对定位是相对于外层的div,绝对定位就是根据浏览器窗口