发表于: 2018-05-14 21:30:54

3 570



今天完成的事情:完成task7
明天计划的事情:开始task8
遇到的问题:

半透明在手机端失效

Footer处的背景在电脑上显示是半透明,在手机端显示全透明,不知道为什么

PC端效果

手机端效果

未解决:半透明在手机端失效


收获:

点击按钮播放音频js代码:

 

    <button id="bf" onclick="bf();">

                            <audio id="music1" controls="controls">

                                               <source src="自由财富.mp3" type="audio/mp3">                                   

                                               Your browser does not support the audio tag.

                            </audio>

         </button >       

         <script>

         function bf(){

                   var audio = document.getElementById('music1');

                    if(audio.paused)                     {                

                             audio.play();//audio.play();// 这个就是播放 

                    }else{

                     audio.pause();// 这个就是暂停

                    }

                   }

 

抽象出来

bbb()是写新函数

    <button id="aaa"  onclick="bbb();" class="样式">

                            <audio id="ccc" class="样式" controls="controls">

                                               <source src="自由财富.mp3" type="audio/mp3">                                   

                                               Your browser does not support the audio tag.

                            </audio>

         </button >       

         <script>

         function bbb(){

                   var xxx = document.getElementById('ccc'); 赋值给xxx,此时xxx代表<audio标签>

                    if(xxx.paused)                     {                

                             xxx.play();//xxx.play();// 这个就是播放 

                    }else{

                     xxx.pause();// 这个就是暂停

                    }

                   }

 

<button id=”switch” onclick=”bgplay()” class=”switch-style”>

<button>

<audio id=”music” class=”bg-style” control=”controls”>

<source src=”路径.格式” type=”audio/对应格式”>

Your browser does not support the audio tag.提示语言

</audio>

 

<script>

         function bgplay(){

                   var audio = document.getElementById('music'); audio赋值给audioaudio可以替换xxx

                    if(audio.paused)                     {                

                             audio.play();//audio.play();// 这个就是播放 

                    }else{

                     audio.pause();// 这个就是暂停

                    }

                   }

</script>

 

 

 

 

页面切换测试

    <button id="bgswitch" onclick="bgplay();" class="switch-style">

    </button >  

    <script>

    function bgplay(){

        window.location.href="./test2.html";}

      

    </script>

目前的理解:

各代码作用:

onclick="bgplay();这句代码相当于是将bgplay()函数与onclick事件绑定起来,即onclick事件发生时,bgplay()函数也得发生

function bgplay(){}这句代码是描述bgplay()函数用的,即bgplay()函数是干啥的

window.location.href=“”;这句代码的意思是跳转页面

注意:函数中不能有连字符

 



半透明设置

rgba()

R

红色值。正整数 | 百分数

G

绿色值。正整数 | 百分数

B

蓝色值。正整数 | 百分数

A

Alpha透明度。取值0~1之间。

·         此色彩模式与RGB相同,只是在RGB模式上新增了Alpha透明度。

·         opacity: value|inherit;

·         value:不透明度,从 0.0 完全透明)到 1.0(完全不透明)。

·         RGBAopacity都是用来设置元素的不透明度的,那么两者有什么区别呢?

·         区别

·         opacity会继承父元素的 opacity 属性,而RGBA设置的元素的后代元素不会继承不透明属性。

·          

报内容...


返回列表 返回列表
评论

    分享到