小编Vas*_*nin的帖子

D3:在DIV中添加样式和类会导致样式被丢弃

我尝试为基于d3的项目实现类似于界面的窗口,但是当我向其中添加classattr DIV并尝试通过left, right它们控制窗口位置时,d3只是忽略了它,而样式标签对于window来说是空的,所以我遇到了一个奇怪的问题DIV

我需要的通用功能是添加和控制窗口位置。

我准备小提琴

这是一个代码:

var addWindow = function(parent, aClass, x, y, width, height) {
    var aWindow = d3.select(parent)
        .append("div")
        .attr("class", aClass)
        .style("top", y)
        .style("left", x)
        .style("width", width)
        .style("height", height);

    aWindow.append("div")
        .attr("class", "window-header-3d")
        .text("List");

    return aWindow;
}

persons_listbox = addWindow(".dia_body", "window-3d", 30, 30, 200, 300);

//persons list
persons_list = persons_listbox.append("ul").attr("class", "window-list-3d")


persons_list.append("li").attr("class", "window-item-3d").text("11111");
persons_list.append("li").attr("class", "window-item-3d").text("12111");
persons_list.append("li").attr("class", "window-item-3d").text("13111");
Run Code Online (Sandbox Code Playgroud)
body {
  background-color:rgba(50,50,50,1);   
}

.window-header-3d {
  width:100%;
  height:30px;
  border-radius:5px;
  background-color:rgba(250,250,250,1);
  z-index:1000;
  position:relative;
  padding-top:5px;
  padding-bottom:5px; …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery d3.js

3
推荐指数
1
解决办法
6796
查看次数

标签 统计

css ×1

d3.js ×1

html ×1

javascript ×1

jquery ×1