How does css realize the proportional display of height and fixed width?

the width and height can be displayed proportionally with the percentage of padding-top. The current demand is that the height is fixed. How to display the width proportionally?

Feb.24,2022

doesn't quite understand what effect you want, just set the percentage relative to the parent element directly by displaying the width proportionally, or use the flex layout. The height proportional display you mentioned earlier using padding-top should take advantage of the percentage setting of padding, which is set relative to the width of the parent element, if so, You can solve your problem directly by using the percentage of width


has found a solution: see here =" https://www.cnblogs.com/beile.


there is a way you can try

for example, if you want to implement a container with an aspect ratio of 1:3 , you can make a 1'3 pixel picture (the smaller the better), and then set the height to the fixed height you want, then the width will be adaptive, and you can set the outside container to float or inline-block

.

this feeling is to set max-height max-width so that it will be adaptive in all cases.

if you say the height is fixed, then you can write a dead height, without setting the width. In this case, the width will be exceeded or not enough. If you just look at the center. Consider left:50%;transtion: tranlstae (- 50%) to pull back.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c584-2c334.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c584-2c334.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?