【问题标题】:How to remove the opacity in javascript?如何删除javascript中的不透明度?
【发布时间】:2013-07-16 19:08:06
【问题描述】:

我有一个视图隐私政策。我为我的 div 添加了不透明度,但现在我不知道如何删除不透明度。我正在尝试删除该属性,但它不起作用。有人可以帮助我吗?这是一个非常紧迫的要求。

<script type="text/javascript">


    function show(id)
    {
       if(document.getElementById("wrapper")) //check the element exists and can be accessed
       {   
           var ele = document.getElementById("wrapper");//get hold of the element
           if(ele.style.visibility=="visible")//see if display property is set to none
           {   
           }
           else
           {
                ele.style.visibility="visible";
               document.getElementById('LOGIN').style.opacity = 0.4;

           }
       }
    } 

    function hide(id)
    {
       if(document.getElementById("wrapper"))//check the element exists and can be accessed
       {    
           var ele = document.getElementById("wrapper");//get hold of the element
           if(ele.style.visibility=="visible")//see if display property is set to none
           {   
               ele.style.visibility="hidden"; 
           }
           else
           {

           }
       }
    } 

</script>
<style>
#wrapper {
position:absolute; 
z-index:1;
top:11%; bottom:5%; left:4%;right:15%;
width:87%;
height:75%;
font-size:15pt;
border:5px solid orange;
border-radius:25px;
overflow:auto;
visibility:hidden;
background-color:#ffffff;

}

#LOGIN.faded {
  opacity: 0.5;

}

</style>
  </head>
  <body >
   <div id="LOGIN" align="center">

            <table width="100%">
                <tr>
                    <td>
                        <input type="image" src="../images/header-sign-up.png" style="width:100%" alt=""/>
                    </td>
                </tr>
            </table>
            <div align="center">
                <a href="#" onclick ="show('showhide');">View privacy policy</a>

            </div>

   </div>
   <div id="wrapper">
                    <div id="scroller" >
                        <div id="popupContact" >
                            <a href="#" onclick ="hide('showhide');">Close Window</a><br/>
                            <p>
                                &nbsp;&nbsp;biler Privacy Policy

                                &nbsp;Please feel free to contact us with any comments, questions, complaints or suggestions you might have regarding the information practices described in this statement. You may send us an e-mail at 
                          </p>  
                        </div>
                    </div>
                </div>
   </body>
</html>

【问题讨论】:

标签: javascript android cordova opacity


【解决方案1】:

尝试现有的不透明度,或显示...

document.getElementById('varContent').style.opacity = 0;
document.getElementById('varContent').style.opacity = 1;

document.getElementById('varContent').style.display = 'none';
document.getElementById('varContent').style.display = 'block';

【讨论】:

    【解决方案2】:

    您必须将opacity 设为1

    【讨论】:

      【解决方案3】:

      基于 web kit 的浏览器将不透明度设置为 1 会(不必要地)减慢显示速度(尤其是在背景图像上滚动不透明度为 1 的内容时)

      最好完全删除该属性(如果您确定它可用,则使用“removeProperty”方法(IE 9 或更高版本):

      element.style.removeProperty("opacity")
      

      或者,更兼容:

      element.style.opacity = ""
      

      【讨论】:

        猜你喜欢
        • 2017-01-31
        • 1970-01-01
        • 2017-03-15
        • 1970-01-01
        • 1970-01-01
        • 2019-08-24
        • 1970-01-01
        • 2014-01-01
        • 2015-01-11
        相关资源
        最近更新 更多