【问题标题】:Making dijit.Dialog Transparent when it shows up使 dijit.Dialog 显示时透明
【发布时间】:2018-12-09 12:52:39
【问题描述】:

我有一个使用dijit.Dialog 库的Dojo Dialog box。它出现在Dojo gridRowclick 事件中。现在当它出现时,我希望它是透明的或降低它的不透明度,这样无论我的背景中的什么我都能看到它,它看起来会很好。我的对话框是一个简单的<div> with data-dojo-type="dijit.Dialog"

代码是::

<div id="terms" name ="hi" data-dojo-type="dijit.Dialog" style="height:580px;width:900px;" data-dojo-props="title:'Control Activities'" preload="true">
<center><p><strong>EDIT AN ACTIVITY </strong></p></center>
<center><table>
<tr style="height: 50px">
<td style="width: 150px" align="right"><b>ASSIGNED BY : &nbsp&nbsp&nbsp</b></td>
<td style="width: 600px" align="left"><div id="plets"><input dojoType="dijit.form.ValidationTextBox" id="dassignedbyid" name="dassignedbyname"  onfocus="hello()" required="true"></div>
<span dojoType="dijit.Tooltip" connectId="dassignedbyid">Enter Name</span></td>
<td style="width: 150px" align="right"><b>ASSIGNED TO : &nbsp&nbsp&nbsp</b></td>
<td style="width: 600px" align="left"><div id="plets1"><input dojoType="dijit.form.ValidationTextBox" id="dassignedtoid" name="dassignedtoname" onfocus="hello()" required="true"></div>
<span dojoType="dijit.Tooltip" connectId="dassignedtoid">Enter Name</span></td></tr>
</table></center>
</div>

Dialog box id= terms 出现在这段代码中 ::

dojo.connect(grid, "onRowClick", grid, function(){
        var items = grid.selection.getSelected();
        dojo.forEach(items, function(item){

            var v = grid.store.getValue(item, "ActID");
            getdetailsfordialog(v);
            function showDialog(){
                dojo.require('dijit.Tooltip');
                dijit.byId("terms").show();
                document.getElementById('closelabelspan').style.display = 'none';
                document.getElementById('holdlabelspan').style.display = 'none';
                document.getElementById('startlabelspan').style.display = 'none';
                document.getElementById('cancellabelspan').style.display = 'none';
                document.getElementById('updatelabelspan').style.display = 'none';
            }

            showDialog();
            }, grid);
      });

现在我希望当这个dialog box(terms) 弹出时它是透明的。我也尝试过一种 CSS,但这对我不起作用::

<style>
div.transbox
  {
  width:900px;
  height:580px;
  background-color:#FFFFFF;
  border:2px solid black;
  opacity:0.6;
  filter:alpha(opacity=60); /* For IE8 and earlier */

  }
</style> 

我使用的是 IE8。

如何做到这一点?谢谢..

函数showDialog()已编辑::

function showDialog(){
                dojo.require('dijit.Tooltip');
                dijit.byId("terms").on("show", function() { dojo.style(this.domNode, "opacity", 0.3); });
                dijit.byId("terms").show();
                document.getElementById('closelabelspan').style.display = 'none';
                document.getElementById('holdlabelspan').style.display = 'none';
                document.getElementById('startlabelspan').style.display = 'none';
                document.getElementById('cancellabelspan').style.display = 'none';
                document.getElementById('updatelabelspan').style.display = 'none';
            }

【问题讨论】:

    标签: html css dojo


    【解决方案1】:

    以编程方式

        var dia = new dijit.Dialog({
            title: "Click me!",
            onShow: function() {
                var me = this;
                // show routine sets opacity to 1, wait till it has and reset
                // second style call sets the underlay as well
                setTimeout(function() {
                    dojo.style(me.domNode, "opacity", 0.4);
                    dojo.style(dojo.byId(me.underlayAttrs.dialogId + me.underlayAttrs["class"]), "opacity", 0.4);
                }, 1000);
            },
            content: 'simple contents'
        });
        dia.startup();
        dia.show();
    

    通过标记;

    <div data-dojo-type="dijit.Dialog" style="height:580px;width:900px;" 
       data-dojo-props="title:'Control Activities'" preload="true">
    
       <script type="dojo/method" data-dojo-event="onShow" data-dojo-args="">
                var me = this;
                // show routine sets opacity to 1, wait till it has and reset
                // second style call sets the underlay as well
                setTimeout(function() {
                    dojo.style(me.domNode, "opacity", 0.4);
                    dojo.style(dojo.byId(me.underlayAttrs.dialogId + me.underlayAttrs["class"]), "opacity", 0.4);
                }, 1000);
       </script>
    </div>
    

    【讨论】:

    • 非常感谢@mschr 的回复。但我没有得到正确的不透明度。虽然代码没有错误。但是当我的对话框出现时,我得到一个简单的白色背景,没有透明度。已经在 Chrome 和 IE8 中尝试过。我在上面编辑了我的代码。看看我是否编辑正确。谢谢
    • 重新检查答案,您的编辑略有偏差,因为每次调用 showDialog 时它都会附加一个侦听器,因此最终会以 X 次调用 dojo.style 结束。而是将 onShow 实现放在你构造它的地方,我展示了它的标记变体以及编程方式
    • 1) 打开你的开发者工具栏; 2) 单击“检查元素” 3) 单击对话框左上角。 3)悬停在层次结构中的元素(通常你会像containerNode一样'高')并找到你想要设置背景的节点。这个节点将有一个CSS类 - 转到你的样式表并为其设置背景颜色特定的类。
    【解决方案2】:

    dijit 对话框 css 样式文件有:.dijitDialogUnderlay 将“backgounrd-color”属性更改为:background-color: #0000;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-22
      • 2012-01-11
      • 1970-01-01
      • 2020-08-09
      • 1970-01-01
      • 2011-02-05
      • 2011-10-29
      相关资源
      最近更新 更多