admin管理员组文章数量:1356566
I'm currently learning coding at school and I am tasked with making a webpage:
sendnoods.neocities
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?
I'm currently learning coding at school and I am tasked with making a webpage:
sendnoods.neocities
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?
Share Improve this question edited Mar 3, 2018 at 20:18 Ronan Boiteau 10.2k7 gold badges38 silver badges59 bronze badges asked Feb 22, 2017 at 14:41 Send NoodsSend Noods 491 silver badge2 bronze badges 3-
2
There are
min-aspect-ratio
andmax-aspect-ratio
operators in CSS media queries. – Pointy Commented Feb 22, 2017 at 14:44 - possible duplicate stackoverflow./q/5725838/3029422 – Ionut Commented Feb 22, 2017 at 14:44
- 2 you should optimize the images, the page load time is ~2000 ms – Ionut Commented Feb 22, 2017 at 14:50
2 Answers
Reset to default 8There 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
You can use aspect-ratio
for this.
So for example just use
@media (aspect-ratio: 16/9){
//ur css
}
本文标签: javascriptChanging CSS depending on if screen is 1691610or 43Stack Overflow
版权声明:本文标题:javascript - Changing CSS depending on if screen is 16:9, 16:10, or 4:3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744019465a2576950.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论