【发布时间】:2020-04-30 10:26:23
【问题描述】:
我有一组 SVG 格式的社交媒体图标,我使用 2em 的高度和宽度属性。但我的背景颜色不是白色。我一直认为这不是问题,直到我尝试通过设置 SVG 的背景颜色来解决问题。出于某种原因,SVG 的背景不是整个 SVG,而是它的一部分。你可以在sn-p中看到它。也许它与 SVG 的 viewBox='0 0 24 24' 属性有关。是否可以将背景设置为匹配 2em x 2em - 就像我设置的 SVG 的大小一样?
没有白色背景,SVG 看起来不太漂亮。
更新:与初始版本相比,我对代码进行了一些更改。现在看起来像这样:
body {background: rgba(78, 192, 253, .7);}
.tg:before {
content: url("data:image/svg+xml,%3Csvg width='2em' height='2em' fill='rgb(0, 136, 204)' viewBox='0 0 24 24' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' xml:space='preserve' xmlns:serif='http://www.serif.com/' style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;'%3E%3Cpath fill='white' d='M19,24l-14,0c-2.761,0 -5,-2.239 -5,-5l0,-14c0,-2.761 2.239,-5 5,-5l14,0c2.762,0 5,2.239 5,5l0,14c0,2.761 -2.238,5 -5,5Z'/%3E%3Cpath d='M19,24l-14,0c-2.761,0 -5,-2.239 -5,-5l0,-14c0,-2.761 2.239,-5 5,-5l14,0c2.762,0 5,2.239 5,5l0,14c0,2.761 -2.238,5 -5,5Zm-2.744,-5.148c0.215,0.153 0.491,0.191 0.738,0.097c0.246,-0.093 0.428,-0.304 0.483,-0.56c0.579,-2.722 1.985,-9.614 2.512,-12.09c0.039,-0.187 -0.027,-0.381 -0.173,-0.506c-0.147,-0.124 -0.351,-0.16 -0.532,-0.093c-2.795,1.034 -11.404,4.264 -14.923,5.567c-0.223,0.082 -0.368,0.297 -0.361,0.533c0.008,0.235 0.167,0.44 0.395,0.509c1.578,0.471 3.65,1.128 3.65,1.128c0,0 0.967,2.924 1.472,4.41c0.063,0.187 0.21,0.334 0.402,0.384c0.193,0.05 0.397,-0.002 0.541,-0.138c0.811,-0.765 2.064,-1.948 2.064,-1.948c0,0 2.381,1.746 3.732,2.707Zm-7.34,-5.784l1.119,3.692l0.249,-2.338c0,0 4.324,-3.9 6.79,-6.124c0.072,-0.065 0.082,-0.174 0.022,-0.251c-0.06,-0.077 -0.169,-0.095 -0.251,-0.043c-2.857,1.825 -7.929,5.064 -7.929,5.064Z'/%3E%3C/svg%3E");
vertical-align: middle;
padding-right: 0.25em;
background-color: #fff;}
.soc {
padding: 0.5em;
}
<fieldset class="fs01">
<legend><a href="https://t.me/grolribasi" class="soc tg" target="_blank">@Grolribasi</a></legend>
<p class="soc">Text goes here</p>
</fieldset>
【问题讨论】: