缩放离子图标SVG至div尺寸

时间:2018-06-22 04:04:09

标签: css svg

如何将这个完美的圆形svg缩放到div的宽度并保持在中心-不再重复。它被放置为背景图像:

g(const int&)

}     

这就是我现在要得到的? enter image description here

如何将svg V和H居中?

1 个答案:

答案 0 :(得分:0)

您可以使用flexbox位置居中,我对此进行了更改:

  • 使用Flexbox.cotainer中的元素居中
  • width上添加了height.play_full

.container {
  border : 1px solid red;
  display: inline-flex;
    justify-content: center;
    align-items: center;
}
.play-full {
  display: inline-block;
  width: 50px;
  height: 50px;
  background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHg9IjBweCIgeT0iMHB4IgogICAgIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIKICAgICB2aWV3Qm94PSIwIDAgMzIgMzIiCiAgICAgc3R5bGU9ImZpbGw6IzAwMDAwMDsiPjxnIGlkPSJzdXJmYWNlMSI+PHBhdGggc3R5bGU9IiAiIGQ9Ik0gMTYgNiBDIDEyLjIzNDM3NSA2IDguOTA2MjUgNi4zOTA2MjUgNi44NzUgNi42ODc1IEMgNS4xOTUzMTMgNi45MzM1OTQgMy44Mzk4NDQgOC4xOTkyMTkgMy41MzEyNSA5Ljg3NSBDIDMuMjY5NTMxIDExLjMwMDc4MSAzIDEzLjM4NjcxOSAzIDE2IEMgMyAxOC42MTMyODEgMy4yNjk1MzEgMjAuNjk5MjE5IDMuNTMxMjUgMjIuMTI1IEMgMy44Mzk4NDQgMjMuODAwNzgxIDUuMTk1MzEzIDI1LjA3MDMxMyA2Ljg3NSAyNS4zMTI1IEMgOC45MTQwNjMgMjUuNjA5Mzc1IDEyLjI1MzkwNiAyNiAxNiAyNiBDIDE5Ljc0NjA5NCAyNiAyMy4wODU5MzggMjUuNjA5Mzc1IDI1LjEyNSAyNS4zMTI1IEMgMjYuODA0Njg4IDI1LjA3MDMxMyAyOC4xNjAxNTYgMjMuODAwNzgxIDI4LjQ2ODc1IDIy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