【发布时间】:2015-11-14 05:23:09
【问题描述】:
我被困住了。我想在我使用 d3 创建的 SVG 图表上添加一个 html 下拉菜单。目前下拉菜单出现在图表下方,但我希望下拉菜单出现在图表上的特定位置。
我不清楚我的问题是浏览器呈现所有元素的顺序,还是仅仅是 CSS 问题。
任何帮助将不胜感激。
这是我的html:
<div class="chartArea">
<select class = "demoSelection"></select></div>
这是我的 CSS:
.chartArea{
position: relative;}
.demoSelection {
position: absolute;
width: 250px;
top:400px;
left:250px;}
这是我在 d3 中创建 SVG 元素的地方:
var svg = d3.select("body").select(".chartArea")
.append("svg")
.attr("id","svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("class","chart");
我稍后用 d3 中的选项填充选择框
d3.select(".demoSelection")
.append("option")
.attr("value",demoCounter)
.text(json.demos[demoCounter].title);
【问题讨论】:
标签: javascript html css d3.js svg