html - 无法显示代码笔图标

标签 html css icons instagram font-awesome

我正在尝试使用 Font Awesome 图标,但看不到 codepen 图标。所有其他图标都可以正常工作。有什么办法可以让新的 Instagram 图标颜色与这种颜色合并?我尝试使用 font awesome 提供的其他图标,它似乎有效。我也尝试用其他图标更改 codepen 图标的位置,但它似乎没有用。另一件事,动画似乎在图标所在的地方起作用,但它没有显示任何东西。

html {
  font-size: 1.5em;
}

body {
  background-color: #fff;
  padding: 10px;
  text-align: center;
}


/* Wrapper */

.icon-button {
  background-color: white;
  /*	border-radius: 2.6rem;*/
  cursor: pointer;
  display: inline-block;
  font-size: 1.3rem;
  height: 2.6rem;
  line-height: 2.6rem;
  margin: 0 5px;
  position: relative;
  text-align: center;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  width: 2.6rem;
}


/* Circle */

.icon-button span {
  /*	border-radius: 0;*/
  display: block;
  height: 0;
  left: 50%;
  margin: 0;
  position: absolute;
  top: 50%;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
  width: 0;
}

.icon-button:hover span {
  border-radius: 25px;
  width: 2.6rem;
  height: 2.6rem;
  /*border-radius: 2.6rem;*/
  margin: -1.3rem;
  /*transform: rotate(20deg);*/
}


/* Icons */

.icon-button i {
  background: none;
  color: white;
  height: 2.6rem;
  left: 0;
  line-height: 2.6rem;
  position: absolute;
  top: 0;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
  width: 2.6rem;
  z-index: 10;
}

.facebook span {
  background-color: #3B5998;
}

.instagram span {
  background-color: #c32aa3;
  /*background-color: linear-gradient(#c32aa3, #c4302b);*/
}

.codepen span {
  background-color: #cb2027;
}

.icon-button .icon-facebook {
  color: #3B5998;
}

.icon-button .fa-instagram {
  color: #c32aa3;
}

.icon-button .fa-codepen {
  color: #cb2027;
}

.icon-button:hover .icon-facebook,
.icon-button:hover .fa-instagram,
.icon-button:hover .fa-codepen {
  color: white;
}

@media all and (max-width: 680px) {
  .icon-button {
    border-radius: 1.6rem;
    font-size: 0.8rem;
    height: 1.6rem;
    line-height: 1.6rem;
    width: 1.6rem;
  }
  .icon-button:hover span {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 1.6rem;
    margin: -0.8rem;
  }
  /* Icons */
  .icon-button i {
    height: 1.6rem;
    line-height: 1.6rem;
    width: 1.6rem;
  }
  body {
    padding: 10px;
  }
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<a href="#" class="icon-button facebook"><i class="icon-facebook"></i><span></span></a>
<a href="#" class="icon-button instagram"><i class="fa fa-instagram"></i><span></span></a>
<a href="#" class="icon-button codepen"><i class="fa fa-codepen"></i><span></span></a>

最佳答案

首先,您需要导入 Font Awesome CSS进入你的例子。

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

由于 <i> 中的错误,我无法显示 Facebook 图标class :

<a href="#" class="icon-button facebook">
  <i class="icon-facebook"></i><span></span>
</a>
<a href="#" class="icon-button instagram">
  <i class="fa fa-instagram"></i><span></span>
</a>

我更改了 Facebook HTML到以下并调整了CSS相应地使图标工作。

<a href="#" class="icon-button facebook">
  <i class="fa fa-facebook"></i><span></span>
</a>

html {
  font-size: 1.5em;
}

body {
  background-color: #fff;
  padding: 10px;
  text-align: center;
}


/* Wrapper */

.icon-button {
  background-color: white;
  /*	border-radius: 2.6rem;*/
  cursor: pointer;
  display: inline-block;
  font-size: 1.3rem;
  height: 2.6rem;
  line-height: 2.6rem;
  margin: 0 5px;
  position: relative;
  text-align: center;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  width: 2.6rem;
}


/* Circle */

.icon-button span {
  /*	border-radius: 0;*/
  display: block;
  height: 0;
  left: 50%;
  margin: 0;
  position: absolute;
  top: 50%;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
  width: 0;
}

.icon-button:hover span {
  border-radius: 25px;
  width: 2.6rem;
  height: 2.6rem;
  /*border-radius: 2.6rem;*/
  margin: -1.3rem;
  /*transform: rotate(20deg);*/
}


/* Icons */

.icon-button i {
  background: none;
  color: white;
  height: 2.6rem;
  left: 0;
  line-height: 2.6rem;
  position: absolute;
  top: 0;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
  width: 2.6rem;
  z-index: 10;
}

.facebook span {
  background-color: #3B5998;
}

.instagram span {
  background-color: #c32aa3;
  /*background-color: linear-gradient(#c32aa3, #c4302b);*/
}

.codepen span {
  background-color: #cb2027;
}

.icon-button .fa-facebook {
  color: #3B5998;
}

.icon-button .fa-instagram {
  color: #c32aa3;
}

.icon-button .fa-codepen {
  color: #cb2027;
}

.icon-button:hover .fa-facebook,
.icon-button:hover .fa-instagram,
.icon-button:hover .fa-codepen {
  color: white;
}

@media all and (max-width: 680px) {
  .icon-button {
    border-radius: 1.6rem;
    font-size: 0.8rem;
    height: 1.6rem;
    line-height: 1.6rem;
    width: 1.6rem;
  }
  .icon-button:hover span {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 1.6rem;
    margin: -0.8rem;
  }
  /* Icons */
  .icon-button i {
    height: 1.6rem;
    line-height: 1.6rem;
    width: 1.6rem;
  }
  body {
    padding: 10px;
  }
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<a href="#" class="icon-button facebook"><i class="fa fa-facebook"></i><span></span></a>
<a href="#" class="icon-button instagram"><i class="fa fa-instagram"></i><span></span></a>
<a href="#" class="icon-button codepen"><i class="fa fa-codepen"></i><span></span></a>

编辑(线性渐变示例)

html {
  font-size: 1.5em;
}

body {
  background-color: #fff;
  padding: 10px;
  text-align: center;
}


/* Wrapper */

.icon-button {
  background-color: white;
  /*	border-radius: 2.6rem;*/
  cursor: pointer;
  display: inline-block;
  font-size: 1.3rem;
  height: 2.6rem;
  line-height: 2.6rem;
  margin: 0 5px;
  position: relative;
  text-align: center;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  width: 2.6rem;
}


/* Circle */

.icon-button span {
  /*	border-radius: 0;*/
  display: block;
  height: 0;
  left: 50%;
  margin: 0;
  position: absolute;
  top: 50%;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
  width: 0;
}

.icon-button:hover span {
  border-radius: 25px;
  width: 2.6rem;
  height: 2.6rem;
  /*border-radius: 2.6rem;*/
  margin: -1.3rem;
  /*transform: rotate(20deg);*/
}


/* Icons */

.icon-button i {
  background: none;
  color: white;
  height: 2.6rem;
  left: 0;
  line-height: 2.6rem;
  position: absolute;
  top: 0;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
  width: 2.6rem;
  z-index: 10;
}

.instagram span {
  background: linear-gradient(#c32aa3, #333333);
}

.icon-button .fa-instagram {
  color: #c32aa3;
}

.icon-button:hover .fa-instagram {
  color: white;
}

@media all and (max-width: 680px) {
  .icon-button {
    border-radius: 1.6rem;
    font-size: 0.8rem;
    height: 1.6rem;
    line-height: 1.6rem;
    width: 1.6rem;
  }
  .icon-button:hover span {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 1.6rem;
    margin: -0.8rem;
  }
  /* Icons */
  .icon-button i {
    height: 1.6rem;
    line-height: 1.6rem;
    width: 1.6rem;
  }
  body {
    padding: 10px;
  }
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<a href="#" class="icon-button instagram"><i class="fa fa-instagram"></i><span></span></a>

关于html - 无法显示代码笔图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55311919/

相关文章:

javascript - 自动搜索的ajax无法正常工作

javascript - 如何使用javascript按tab键访问div?

javascript - 相对于鼠标位置定位 div

javascript - 什么可能导致 CKEditor 图标丢失?

html - 单元格填充中的 X 和 Y =""

html - 使用 SVG 玩 Gooey 效果

php - 将遗留 html 表格设计导入 div 布局

html - 与 CSS 标志形状背景的链接

react-native - 在哪里放置我的图标图片供世博会使用而不是默认图片?

c# - 为我所有的表单设置相同的图标