gpt4 book ai didi

html - 在 html 中使用媒体查询

转载 作者:太空宇宙 更新时间:2023-11-04 16:24:20 27 4
gpt4 key购买 nike

我写了一个简单的 HTML 程序用于实验目的:
这是代码:

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: green;
}

@media screen and (device-height: 375px) and (device-width: 667px) {
body {
background-color: blue;
}
}
</style>
</head>
<body>

<p>Media queries are simple filters that can be applied to CSS styles. They make it easy to change styles based on the characteristics of the device rendering the content, including the display type, width, height, orientation and even resolution.</p>

</body>
</html>

但是ut在iPhone 6上试了一下没有变色,代码有什么问题吗?逻辑表达是否正确?

最佳答案

这对我适用于 iphone 6:

@media only screen and (min-device-width: 374px) and (max-device-width: 376px)

这适用于 iphone 6+:

@media only screen and (min-device-width: 413px) and (max-device-width: 415px)

关于html - 在 html 中使用媒体查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26712723/

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