调整图标大小并居中对齐圆圈内

时间:2019-02-23 09:30:05

标签: html css flexbox

我有一个网络图标列表,我试图将它们显示为带有白色背景的圆圈。这就是我现在所拥有的。我正在尝试使图标适合圆圈。

.logo {
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-justify-content: center;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: #1e1e1e;
  width: 100%;
  height: 100%;
  max-height: 88px;
  max-width: 88px;
  margin: 0 auto;
  background: url('/networks/network-logo-bg@2x.png') center center no-repeat;
  background-size: contain;
  img {
    width: 80%;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    color: #000;
    margin: 0 auto;
    @include lazyLoad(null);
  }
}

HTML:

<div key={index} className="logo">
            <img  className="lazyload" src={logo.icon} alt={logo.name}/>
          </div>

icon not aligned to center

我希望图标位于圆圈内并与中心对齐。

1 个答案:

答案 0 :(得分:1)

您可以尝试以下操作:

HTML:

<div class="circle">
  <img src="https://image.flaticon.com/icons/svg/826/826356.svg">
</div>

CSS:

.circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background-color: black;
  display: flex;
  justify-content: center;
}

img {
  width: 50%;
}

Demo

相关问题