gpt4 book ai didi

css - 设置 1 :1 square image to be 10% of the screen height and width css

转载 作者:行者123 更新时间:2023-11-28 17:28:51 26 4
gpt4 key购买 nike

将最大高度设置为页面高度的 10%。最大宽度为页面宽度的 10%

例如如果

页面高度为100px

页面宽度为200px

或者

页面高度为200px

页面宽度为100px

我希望我的图片设置为 10px 宽和 10px 高

10%,以较小者为准;页面的高度或宽度。

我试过了

width: 10%;
height: 0;
padding-bottom: 10%;

max-width: 10%;
max-height: 10%;

但它们只受页面宽度的影响,而不是高度。

最佳答案

想通了

width: 10vmin; 
height: 10vmin;

CSS做两者中较小者的 10%,高度或宽度

http://caniuse.com/#feat=viewport-units

关于css - 设置 1 :1 square image to be 10% of the screen height and width css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26568727/

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