html - 如何使用基础图标更改列表项样式?

标签 html css zurb-foundation

我已经下载了一组基础图标,但我很难找到有关如何在我的 CSS 代码中使用这些图标的文档。

我知道我可以在我的标记中使用它:

<i class="fi-check"></i>

但我想将它包含在我的 css 文件中

@import url("foundation-icons/foundation-icons.css");

并在这里开始使用它们。例如,我想将所有列表项样式更改为复选标记。基本上我想要的是:

.myClass li { list-style: fi-check; }

是否有可能以某种方式做到这一点?

最佳答案

正如您所指出的,在您的标记中使用它们是最简单的。

<i class="fi-check"></i>

但是,如果您想为自己的自定义样式重新创建它,则必须重新创建/更改 foundation-icons.css

中的 css 规则

首先你需要引入@font-face:

@font-face {
  font-family: "foundation-icons";
  src: url("foundation-icons.eot");
  src: url("foundation-icons.eot?#iefix") format("embedded-opentype"),
       url("foundation-icons.woff") format("woff"),
       url("foundation-icons.ttf") format("truetype"),
       url("foundation-icons.svg#fontcustom") format("svg");
  font-weight: normal;
  font-style: normal;
}

然后您需要像这样将它添加到您的自定义 CSS 中:

.myClass li:before {
  font-family: "foundation-icons";
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  display: inline-block;
  text-decoration: inherit;

  content: "\f126";
}

最后一行引用了 foundation-icons 文件中的 check 图标。因此,如果您想将图标更改为其他内容,您需要查看 foundation-icons.css 以查看将哪些代码放入 content 部分。

例如:

trash = content: "\f204";
stop = content: "\f1ef";

希望这是有道理的!

关于html - 如何使用基础图标更改列表项样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29123715/

相关文章:

jquery - Zurb Foundation 顶部栏菜单无法在移动显示屏上运行

每张幻灯片上的 jQuery Cycle 全宽包装器

html - phonegap 的 css - 如何让三个列表项平均共享页面?

html - CSS radio 选中的标签唯一颜色

css - 基础网格系统不适用于 Angular Form

css - 如何手动设置 "foundation watch"端口?

html - 我如何将菜单按钮放在左侧?

php - 在 Laravel 中同时保存数据和附加

html - 按钮中的垂直文本

jquery - 网站右侧空间