html - 内联 CSS 问题

标签 html css

我正在尝试使我的 CSS 内联,但这给了我一些问题。我正在使用 font-awesome,并且我有:

@font-face {
  font-family: 'FontAwesome';
  src: url('font/fontawesome-webfont.eot');
  src: url('font/fontawesome-webfont.eot?#iefix') format('embedded-opentype'), url('font/fontawesome-webfont.woff') format('woff'), url('font/fontawesome-webfont.ttf') format('truetype'), url('font/fontawesome-webfont.svg#FontAwesome') format('svg');
  font-weight: normal;
  font-style: normal;
}

在 CSS 中。所以当它被内联时,它不起作用(我在页面上看不到任何图标)。这是否意味着我不能内联执行此操作?

附加信息:

html:

<style type="text/css">
@font-face {
  font-family: 'FontAwesome';
  src: url('font/fontawesome-webfont.eot');
  src: url('font/fontawesome-webfont.eot?#iefix') format('embedded-opentype'), url('font/fontawesome-webfont.woff') format('woff'), url('font/fontawesome-webfont.ttf') format('truetype'), url('font/fontawesome-webfont.svg#FontAwesome') format('svg');
  font-weight: normal;
  font-style: normal;
}

.icon-wrench:before {
  content: "\f0ad";
}
</style>

<i class="icon-wrench"></i>

当我像这样链接到样式表时它显示正确:

<link href="style.css" rel="stylesheet">

但不是,用上面介绍的方法好像是。

最佳答案

试试这个:

@font-face {
    font-family: 'FontAwesome';
    src: url('font/fontawesome-webfont.eot');
    src: local('☺'), url('font/fontawesome-webfont.woff') format('woff'), url('font/fontawesome-webfont.ttf') format('truetype'), url('font/fontawesome-webfont.svg') format('svg');
    font-weight: normal;
    font-style: normal;
}

我使用它,它适用于所有浏览器。

关于html - 内联 CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16832717/

相关文章:

html - 水平对齐 youtube 响应式 youtube 视频

javascript - 单击并重新单击 div 标记的两个事件

Chrome 中的 CSS 缩放动画不流畅

php - 针对 wordpress 背景的另一个图像

html - 为什么这个技巧在动态高度 div 中垂直居中文本(以及它为什么会中断)?

java - Selenium (Java): ordered list of webelements but with nested divs

javascript - 无效属性 : expected Array, 但未定义

java - JApplet在HTML页面中运行失败

html - 绝对定位 "pop-up"的问题

javascript - 将元素 display none 改回默认样式值 JS