【发布时间】:2021-04-08 14:30:51
【问题描述】:
我有一个简单的搜索图标作为我正在使用的 SVG,但由于某种原因,当我加载我的网页时,尽管有 24x24 锁定,它还是很大CSS 和 SVG 本身的样式。
它会展开并占据整个页面,直到所有内容都加载完毕,然后它会对齐到正常的 24x24 尺寸。这看起来非常荒谬,我知道我一定做错了什么。有任何想法吗?
SVG:
<svg style="position: absolute; width: 0; height: 0;" width="0" height="0" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-search" class="icon" viewBox="0 0 24 24">
<title>search</title>
<circle class="st0" cx="9.3" cy="9.2" r="8.6" />
<line class="st1" x1="15.3" y1="15.4" x2="23.3" y2="23.4" />
</symbol>
</defs>
HTML:
<div class="searchContainer">
<div class="search">
<input class="image" type="image" src="images/search.svg"><input class="text" type="text" onfocus="if(this.value == 'Search') { this.value = ''; }" value="Search" onblur="if (this.value == '') { this.value = 'Search'; }">
</div><!-- /search -->
</div><!-- /searchContainer -->
CSS:
input.image{
fill: black;
width: 24px;
height: 24px;
border: 0;
padding-top: 9px;
text-align: right;
}
Here 是我在加载时看到的。
请注意,其他图标也是 SVGs,但它们是在单个文件中完成的,而我无法在搜索输入中使用这种方法。
<svg><use xlink></use></svg>
任何帮助表示赞赏。谢谢!
【问题讨论】: