I have circles lined up using flexbox and they look decent on small screen width:
我有使用flexbox排列的圆圈,它们在小屏幕宽度上看起来很不错:
but as soon as I widen the width of my screen, they look really stretched. But I need them to be round from every prospect.
但是当我加宽屏幕的宽度时,它们看起来非常紧张。但是我需要他们来自每个前景。
I'm not sure maybe there is a way that fixes their displaying on different screen sizes. Maybe I could have used some media queries. How to handle this?
我不确定是否有办法可以修复不同屏幕尺寸的显示效果。也许我可以使用一些媒体查询。怎么办呢?
HTML
<div class="dashboard-grey-menu">
<div class="flex row no-padding">
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
</div>
</div>
CSS
.dashboard-grey-menu {
height: 30vh;
background-color: #959595;
}
.circle {
border-radius: 50%;
width: 15vw;
height: 25vh;
background-color: #B7B7B7;
margin: auto;
}
.flex {
display: flex;
justify-content: center;
align-items: center;
height: 30vh;
width: 100%;
}
1 个解决方案
#1
7
You have to set the width
and height
of your circle to the same value:
您必须将圆的宽度和高度设置为相同的值:
.dashboard-grey-menu {
height: 30vh;
background-color: #959595;
}
.circle {
border-radius: 50%;
width: 10vw;
height: 10vw;
background-color: #B7B7B7;
margin: 20px;
}
.flex {
display: flex;
justify-content: center;
align-items: center;
height: 30vh;
width: 100%;
}
<ion-content has-header="false">
<div class="dashboard-grey-menu">
<div class="flex row no-padding">
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
</div>
</div>
</ion-content>
#1
7
You have to set the width
and height
of your circle to the same value:
您必须将圆的宽度和高度设置为相同的值:
.dashboard-grey-menu {
height: 30vh;
background-color: #959595;
}
.circle {
border-radius: 50%;
width: 10vw;
height: 10vw;
background-color: #B7B7B7;
margin: 20px;
}
.flex {
display: flex;
justify-content: center;
align-items: center;
height: 30vh;
width: 100%;
}
<ion-content has-header="false">
<div class="dashboard-grey-menu">
<div class="flex row no-padding">
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
<div class="col"><div class="circle"></div></div>
</div>
</div>
</ion-content>