gpt4 book ai didi

css - 根据屏幕百分比配置最大高度

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

我正在使用以下 CSS 来调整滚动框的高度:

.scroll 
{
//max-height: 750px;
max-height: 400px;
overflow-y: auto;
overflow-x: hidden;
}

我想使用 750px,但这对于分辨率较小的屏幕来说太高了。 400px 适用于较小的分辨率,但在较大的屏幕上看起来很糟糕。有没有办法按百分比指定这样的东西?当我尝试 100% 时,它会破坏我的滚动框并使用整个屏幕。

最佳答案

一种解决方案是使用 CSS media queries :

@media(max-width:767px){ /* change the max-width to suit your needs */
.scroll {
max-height: 400px;
}
}

@media(min-width:768px){ /* change the min-width to suit your needs */
.scroll {
max-height: 750px;
}
}

关于css - 根据屏幕百分比配置最大高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25292648/

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