Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing CSS depending on if screen is 16:9, 16:10, or 4:3

I'm currently learning coding at school and I am tasked with making a webpage:

sendnoods.neocities.org

I've already got all of the main graphics and layout I need for 16:9 resolution and 16:10 resolution, but don't know how to implement a different css with those scales.

I know I can set the max-width using:

@media (max-width: 800px) { 
/* CSS that should be displayed if width is equal to or less than 800px goes here */
}

But is there a way I can more generalize it for 16:9, 16:10 and 4:3 resolutions?

like image 731
Send Noods Avatar asked Nov 16 '25 10:11

Send Noods


1 Answers

There is aspect-ratio which can be used in media queries, for example:

@media screen and (aspect-ratio: 16/9) {
  ...
}

It specifies the width/height ratio of the display area.

"min-" and "max-" prefixes can be used, like max-aspect-ratio:16/9

like image 187
Johannes Avatar answered Nov 18 '25 06:11

Johannes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!