通过执行类似于this(d3.select(..).append("div")
)的代码,我得到具有此类样式属性的div
:
<div id="id6"
style="
background-image: initial;
background-attachment: initial;
background-origin: initial;
background-clip: initial;
background-color: rgb(255, 255, 255);
background-position: initial initial;
background-repeat: initial initial; ">
5
</div>
问题:
initial
来自哪里? b)是否可以重新定义“默认值”?background-position: initial initial;
和
background-repeat: initial initial;
是Invalid property value
。这是d3的错误吗?我们如何处理这个错误?答案 0 :(得分:5)
这与D3无关,但具有CSS的隐含性质。指定CSS background property时,实际上是以速记方式指定多个属性。例如,
background: url(chess.png) gray 50% repeat fixed;
实际上是
的简写background-image: url(chess.png);
background-color: gray;
background-position: 50% 50%;
background-repeat: repeat;
background-attachment: fixed;
因此,当您设置样式“背景”时,您的浏览器会自动将此简写扩展为完整表单。这就是为什么你会看到所有这些额外的风格;它们代表computed values。