将图标徽标置于圆圈中心?

问题描述 投票:0回答:1

screenshot#代码在CodePen中是完美的,我在firfox或chrome中运行时出现这个问题。我用“line-hight”在“浏览器检查”中修复了它,但是当我在 VScode 中编写解决方案时,没有任何问题得到解决。代码在 CodePen 中是完美的,我在 firfox 或 chrome 中运行时出现了这个问题。我将其修复了“浏览器检查”和“行高”,但是当我在 VScode 中编写解决方案时,没有解决任何问题。

.card21 {
  grid-area: z;
  background-color: #000;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.socials {
  width: 550px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px;
}

ul {
  display: contents;
  transform: translate(-50%, -50%);
  border-radius: 15px;
  margin: 0 auto;
}

ul li {
  list-style: none;
}

ul li a {
  width: 80px;
  height: 80px;
  background-color: #fff;
  text-align: center;
  line-height: 0px;
  font-size: 35px;
  margin: 0 10px;
  display: block;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  border: 3px solid #fff;
  z-index: 1;
  margin-bottom: 20px;
  flex-basis: 50%; // this makes sure there are two items per row
}

ul li a .icon {
  position: relative;
  color: #262626;
  transition: .5s;
  z-index: 3;
}

ul li a:hover .icon {
  color: #fff;
  transform: rotateY(360deg);
}

ul li a:before {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f00;
  transition: .5s;
  z-index: 2;
}

ul li a:hover:before {
  top: 0;
}

ul li:nth-child(1) a:before {
  background: #3b5999;
}

ul li:nth-child(2) a:before {
  background: #55acee;
}

ul li:nth-child(3) a:before {
  background: #0077b5;
}

ul li:nth-child(4) a:before {
  background: #dd4b39;
}
<div class="box card21">
  <div class="socials">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
    <ul>
      <li>
        <a href="#"> <i class="fab fa-facebook-f icon"></i>
        </a>
      </li>
      <li>
        <a href="#"><i class="fab fa-twitter icon"></i></a>
      </li>
      <li>
        <a href="#"><i class="fab fa-linkedin-in icon"></i></a>
      </li>
      <li>
        <a href="#"><i class="fab fa-google icon"></i></a></li>
      <li>
        <a href="#"><i class="fab fa-telegram icon"></i></a></li>
      <li>
        <a href="#"><i class="fab fa-behance icon"></i></a></li>
    </ul>
  </div>
</div>

html css icons contacts footer
1个回答
0
投票

检查这个

.card21 {
  grid-area: z;
  background-color: #000;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.socials {
  width: 550px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px;
}

ul {
  display: contents;
  transform: translate(-50%, -50%);
  border-radius: 15px;
  margin: 0 auto;
}

ul li {
  list-style: none;
}

ul li a {
  width: 80px;
  height: 80px;
  background-color: #fff;
  text-align: center;
  line-height: 0px;
  font-size: 35px;
  margin: 0 10px;
  display: block;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  border: 3px solid #fff;
  z-index: 1;
  margin-bottom: 20px;
  flex-basis: 50%; // this makes sure there are two items per row
}

ul li a .icon {
  position: relative;
  padding: 25%;
  color: #262626;
  transition: .5s;
  z-index: 3;
}

ul li a:hover .icon {
  color: #fff;
  transform: rotateY(360deg);
}

ul li a:before {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f00;
  transition: .5s;
  z-index: 2;
}

ul li a:hover:before {
  top: 0;
}

ul li:nth-child(1) a:before {
  background: #3b5999;
}

ul li:nth-child(2) a:before {
  background: #55acee;
}

ul li:nth-child(3) a:before {
  background: #0077b5;
}

ul li:nth-child(4) a:before {
  background: #dd4b39;
}
<div class="box card21">
  <div class="socials">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
    <ul>
      <li>
        <a href="#"> <i class="fab fa-facebook-f icon"></i>
        </a>
      </li>
      <li>
        <a href="#"><i class="fab fa-twitter icon"></i></a>
      </li>
      <li>
        <a href="#"><i class="fab fa-linkedin-in icon"></i></a>
      </li>
      <li>
        <a href="#"><i class="fab fa-google icon"></i></a></li>
      <li>
        <a href="#"><i class="fab fa-telegram icon"></i></a></li>
      <li>
        <a href="#"><i class="fab fa-behance icon"></i></a></li>
    </ul>
  </div>
</div>

© www.soinside.com 2019 - 2024. All rights reserved.