首页 > 解决方案 > 有没有办法在 Draw2D 驱动的画布上拥有 iframe 元素?

问题描述

我正在使用 Draw2D 构建自定义对象,并希望利用 Microsoft 提供的基于 CSS 的材料设计图标 ( https://cdn.materialdesignicons.com/3.6.95/ )。我认为我可以实现这一点的唯一方法是加载 css 类的内部框架。

this.img = new draw2d.shape.basic.Rectangle({
  stroke: 2,
  bgColor: "#ffffff",
  color: "#343F48",
  resizeable: true
});

//replace this with MDI css icons
/ var icon = new draw2d.shape.icon.Db({
/   height: 20,
/   width: 20
/ });
/ icon.setBackgroundColor("#e0ba23");
//

var centerLocator = new draw2d.layout.locator.CenterLocator();
this.img.add(icon, centerLocator);

标签: cssiframedraw2d

解决方案


在初始化形状时,我调用了这个函数来添加和定位插入的 DOM 元素。

positionIcon: function () {
  this.img.overlay = $("<div class='mdi mdi-database overlay'></div>");
  this.img.overlay.css({
    "top": this.getY(),
    "left": this.getX(),
    "color": "#e0ba23",
    "fontSize": 16,
    "padding": 7
  });
  $("#canvas").append(this.img.overlay);
}

您看到的 css 类overlay只是position: absolute.


推荐阅读