每当我将SVG插入到我的网格布局中时,1)就不会居中,而2)会破坏网格的布局。我如何修复这个问题,使播放图标显示的方式与播放文本一样。
下面是正在打破的布局:
.body { background-color: hsl(0,0%,10%); color: white; font-size: 32px; }
.center_children { display: flex; justify-content: center; }
.timer
{
width: 12rem; height: 12rem; border-radius: 50%;
background-color: hsl(0, 50%, 50%);
display:grid; grid-template-rows: 2fr 1fr; gap: 1.5rem;
}<div class="body">
<br />
<div class="timer">
<div class="center_children">
<div class="play">Play</div>
</div>
<div class="center_children">1:39</div>
</div>
<br />
</div>
<br /><br />
<div class="body">
<br />
<div class="timer">
<div class="center_children">
<div class="play">
<svg width="100%" height="100%" viewBox="0 0 100 100" ><polygon points="0,0 75,50 0,100" style="fill:#fff;" /></svg>
</div>
</div>
<div class="center_children">1:39</div>
</div>
<br />
</div>
发布于 2022-06-07 20:05:58
下面是代码中的问题:
alignment.
fr fr.%来调整列的中心位置。如果您想要显示整个图像,则不需要为SVG指定一个下面是修正的代码(添加一些填充以使事物看起来更完美相对于圆圈):
.body { background-color: hsl(0,0%,10%); color: white; font-size: 32px; }
.timer
{
width: 12rem; height: 12rem; border-radius: 50%;
background-color: hsl(0, 50%, 50%);
display:grid; grid-template-rows: 66% 33%;
grid-template-columns: 5rem;
justify-content: center;
}<div class="body">
<div class="timer">
<div class="play">
<svg width="100%" height="100%" ><polygon points="0,0 75,50 0,100" style="fill:#fff;" /></svg>
</div>
<div>1:39</div>
</div>
</div>
https://stackoverflow.com/questions/72531409
复制相似问题