html - 尝试使用独特的超赞字体图标定位每个链接

标签 html css font-awesome

尝试使用 Font-Awesome 图标定位每个事件链接。我正在尝试使用“Content:before”和“a::first-child”的组合。

用图标定位第三个 a 链接“联系我们”,无效。尝试了很多组合。这可能吗? xD

.children.windowbg > a::first-child before{
  content: "\f114";
  font-family: fontawesome !important;
  padding-right:5px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<td class="children windowbg" colspan="3">
							<strong>SUB-FORUMS</strong>: <a href="#">Report Copyright Violations</a>, <a href="#">Disclaimer</a>, <a href="#">Contact Us</a>, <a href="#">Privacy policy</a>
						</td>

?

https://jsfiddle.net/rr78gfw1/

最佳答案

.windowbg  a:nth-of-type(1):before{
  content: "\f114";
  font-family: fontawesome !important;
  margin-left: -23px;
  position :absolute;
  color:red;
  font-size:20px;
}

.windowbg  a:nth-of-type(2):before{
  content: "\f115";
  font-family: fontawesome !important;
  margin-left: -23px;
  position :absolute;
  color:red;
  font-size:20px;
}

.windowbg a
{
  margin-left:25px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="children windowbg" colspan="3">
							<strong>SUB-FORUMS</strong>: <a href="#">Report Copyright Violations</a>, <a href="#">Disclaimer</a>, <a href="#">Contact Us</a>, <a href="#">Privacy policy</a>
						</div>

这里提到的一些解决方案并不是纯粹的 CSS 解决方案,因为它们要求您更改 DOM 结构。

你没有正确使用选择器,在 before :P 之前没有 : 并且 a 不是第一个 child 。使用 nth-of-为此输入选择器。

此外,如果没有 table,你不能使用 td 标签。我的演示是在用 div 替换 td 之后。

像这样,

.windowbg  a:nth-of-type(1):before{
  content: "\f114";
  font-family: fontawesome !important;
  margin-left: -23px;
  position :absolute;
  color:red;
  font-size:20px;
}

fiddle 链接:https://jsfiddle.net/rr78gfw1/1/

关于html - 尝试使用独特的超赞字体图标定位每个链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36534069/

相关文章:

html - CSS:防止带有文本内容的子元素增大窗口大小

css - 如何使用 font-awesome 控制字体粗细

html - 相同高度的 div + 响应式设计 - bootstrap

html - 背景图像未在 css 中显示

html - 顶部边框和文本问题

php - PHP if 语句中缺少 HTML 元素且格式不正确

css - 删除浏览器中滚动时的弹跳,位置 :fixed div 出现问题

java - FontAwesomeIconView 在 SceneBuilder 中显示图标,但在应用程序中失败

html - 有时 Font Awesome 只显示矩形和数字

html - 以编程方式删除 CSS 类文件 - jQuery