2
我创建了以下svg
元素和结构内:SVG OPTION元素
<svg width="135" height="15">
<rect width="15" height="15" fill="#ffffe5" x="0" y="0"></rect>
<rect width="15" height="15" fill="#f7fcb9" x="15" y="0"></rect>
<rect width="15" height="15" fill="#d9f0a3" x="30" y="0"></rect>
<rect width="15" height="15" fill="#addd8e" x="45" y="0"></rect>
<rect width="15" height="15" fill="#78c679" x="60" y="0"></rect>
<rect width="15" height="15" fill="#41ab5d" x="75" y="0"></rect>
<rect width="15" height="15" fill="#238443" x="90" y="0"></rect>
<rect width="15" height="15" fill="#006837" x="105" y="0"></rect>
<rect width="15" height="15" fill="#004529" x="120" y="0"></rect>
</svg>
将会产生小广场的一排。就像这样:
到目前为止,一切正常。
然后我将代码上方的option
为select
下拉内,如下所示:
<select id="data-color-scheme">
<option id="YlGn">
<div>
<svg width="135" height="15">
<rect width="15" height="15" fill="#ffffe5" x="0" y="0"></rect>
<rect width="15" height="15" fill="#f7fcb9" x="15" y="0"></rect>
<rect width="15" height="15" fill="#d9f0a3" x="30" y="0"></rect>
<rect width="15" height="15" fill="#addd8e" x="45" y="0"></rect>
<rect width="15" height="15" fill="#78c679" x="60" y="0"></rect>
<rect width="15" height="15" fill="#41ab5d" x="75" y="0"></rect>
<rect width="15" height="15" fill="#238443" x="90" y="0"></rect>
<rect width="15" height="15" fill="#006837" x="105" y="0"></rect>
<rect width="15" height="15" fill="#004529" x="120" y="0"></rect>
</svg>
</div>
</option>
</select>
现在option
的内容被显示为白色空白,如下面的图像中:
正如你所看到的图像的内容是空的。但是,如果我运行调试检查器,则仍然可以在那里检测到svg
元素。
我在做什么错?如何在选项内显示svg
?谢谢。
谢谢,但:( – Greeso