如何将面板的背景颜色设置为透明

How to set Background color of Panel to transperent

我已将我的面板配置设置为:bodyStyle: 'background:transparent;' 但它不起作用。我也试过:defaults: { bodyStyle: 'background:transparent;' }.

function cre1ColumnHboxForModErrMsg(itemA){
    var hb = new Ext.Panel(
        {   layout:'fit'
            ,height:75
            ,frame: false
            ,border: false
            ,bodyStyle: 'background:transparent;'
            ,layoutConfig:{ align:'top', pack:'center' }
            ,defaults:{ layout:'form', labelWidth:CampConst.CampModErrMsgLabelWidth ,width:175,border:false}
            ,items:[
                {   width:((CampConst.CampModErrMsgWidth/2)-30)
                    ,defaults:{ labelSeparator:'', msgTarget:'side', selectOnFocus:true,anchor:'95%' }
                    ,items:[
                        itemA
                    ]
                }
            ]
        }
    );
    return hb;
}

我哪里错了?

试试 style: 'background:transparent;' - 这适用于整个面板元素,而不仅仅是主体。

不过话虽这么说,但您似乎真的不需要面板,可以用容器代替:

function cre1ColumnHboxForModErrMsg(itemA){

    var hb = new Ext.Panel(
        {   layout:'fit'
            ,height:75
            ,frame: false
            ,border: false
            ,bodyStyle: 'background:transparent;'
            ,layoutConfig:{ align:'top', pack:'center' }
            ,defaults:{ layout:'form', labelWidth:CampConst.CampModErrMsgLabelWidth ,width:175,border:false}
            ,items:[
                {   width:((CampConst.CampModErrMsgWidth/2)-30)
                    ,defaults:{ labelSeparator:'', msgTarget:'side', selectOnFocus:true,anchor:'95%' }
                    ,items:[
                        itemA
                    ]
                }
            ]
        }
    );
    return hb;
}