透明模态背景

时间:2016-06-16 15:39:45

标签: angular-ui-bootstrap

我试图让模态背景完全透明(特别是对于一个模态),并且我很难实现这一目标。从文档中我可以使用backdropClass应用自定义类。当我打开我的模态时,我打电话给:

public class JImagePanel extends JPanel {

  private static final int DEFAULTX = 0;
  private static final int DEFAULTY = 0;
  private static final int DEFAULTWIDTH = 1100;
  private static final int DEFAULTHEIGHT = 700;

  private BufferedImage img;
  private int imagex;
  private int imagey;
  private int imagewidth;
  private int imageheight;
  private static final long serialVersionUID = 1L;

  public JImagePanel(String path){
        super();
        this.imagex=JImagePanel.DEFAULTX;
        this.imagey=JImagePanel.DEFAULTY;
        this.imagewidth=JImagePanel.DEFAULTWIDTH;
        this.imageheight=JImagePanel.DEFAULTHEIGHT;
        img = loadImage(path);
  }

  public JImagePanel(String path,int x,int y, int width, int height){
        super();
        this.imagex=x;
        this.imagey=y;
        this.imagewidth=width;
        this.imageheight=height;
        img = loadImage(path);
  }

  @Override
  protected void paintComponent(Graphics graphics) {
        super.paintComponent(graphics);

       setOpaque(false);
       graphics.drawImage(img, imagex, imagey,imagewidth,imageheight, null);
  }
}

但无论我在这个类中添加什么样式(无论是实现透明度还是仅改变背景颜色),背景都不会改变。我的CSS看起来像这样:

backdropClass: 'transparent-backdrop'

我可以使用windowClass(以及' in'类)修改背景颜色:

.transparent-backdrop {
    opacity: 0;
}

但是,如果我尝试以类似的方式设置不透明度:

windowClass: 'my-window-class'

.my-window-class.in {
   background-color: #000;
}

我的背景仍然存在,但现在我的模态消失了。谁能告诉我修改背景不透明度的正确方法?

1 个答案:

答案 0 :(得分:2)

这对我有用:

.transparent-backdrop.in { opacity: 0; }

这是一个显示Chrome中透明背景的屏幕截图 screenshot