有没有推荐的方法让图标字体(例如FontAwesome / Octicons)渗透到Shadow DOM中?
目前,当我想在自定义元素的Shadow DOM中使用图标时,我必须在Shadow DOM中内联包含ociticons.css
文件的部分内容:
#shadowroot
<style>
.octicon, .mega-octicon {
font: normal normal normal 16px/1 octicons;
display: inline-block;
text-decoration: none;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.mega-octicon { font-size: 32px; }
.octicon-search:before { content: '\f02e'} /* */
</style>
<button>
<span class="mega-octicon octicon-search"></span>
</button>
(显然,
@font-face
会渗入Shadow DOM。)