gpt4 book ai didi

html - 圆形 div 计算宽度不正确导致不是圆形

转载 作者:太空宇宙 更新时间:2023-11-04 09:34:47 25 4
gpt4 key购买 nike

我有一些圆形 div(使用大边框半径),它们在使用媒体查询的不同屏幕尺寸上大小不同。但是,宽度在某些媒体查询大小上不正确。例如,这是超小型设备的屏幕截图:

enter image description here

图像显示宽度和高度在 css 中设置为 80px,但计算出的宽度为 63px。

当我将屏幕拖动得更宽时,我看到圆圈逐渐变宽,直到它们变成圆圈,有点像“响应式”div,而不是仅在特定宽度断点处改变大小的 div。

这是一个 jsfiddle:

http://jsfiddle.net/52VtD/15513/

如何让圆形 div 始终为圆形(宽度与高度相同)?

html:

CSS:

#about-page {
height: 100%;
padding-top: 57px;
width: 100%;
overflow-y: auto;
overflow-x: auto;
min-height: 480px;
justify-content: center;
color: black;
background-color: white;
}
#content-container {
h1, h2, h3, h4, h5, h6 {
text-align: center;
text-transform: uppercase;
font-weight: 200;
}
}
.circle-container {
display: inline-flex;
margin-bottom: 40px;
width: 100%;
justify-content: center;
}
.circle {
border-radius: 75px;
border: 1px solid black;
display: inline-flex;
}
/* xs */

@media only screen and (min-width: 320px) {
.circle {
height: 80px;
width: 80px;
margin: 5px;
}
}
/* s */

@media only screen and (min-width: 544px) {
.circle {
height: 110px;
width: 110px;
margin: 5px;
}
}
/* m */

@media only screen and (min-width: 768px) {
.circle {
height: 120px;
width: 120px;
margin: 8px;
}
}
/* L */

@media(min-width:992px) {
.circle {
height: 130px;
width: 130px;
margin: 10px;
}
}
/* xl */

@media only screen and (min-width: 1200px) {
.circle {
height: 150px;
width: 150px;
margin: 10px;
}
}

最佳答案

您正在使用 flexbox(特别是 inline-flex),因此默认情况下,圆圈将缩小以适合容器元素。为防止这种情况,请设置 flex-shrink: 0flex: 0 0 auto; 以防止这种行为。

.circle {
border-radius: 75px;
border: 1px solid black;
display: inline-flex;
flex: 0 0 auto;
}

http://jsfiddle.net/52VtD/15520/

关于html - 圆形 div 计算宽度不正确导致不是圆形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40443587/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com