【发布时间】:2013-12-06 15:42:40
【问题描述】:
我目前正在为个人项目设计一个登陆页面,我考虑使用屏幕覆盖图像(浏览器窗口的 100% 宽度和 100% 高度)来完善体验。
在通常的标准化之后,我开始了
html, body {
height: 100%;
overflow: hidden;
}
#hero {
width: 100%;
min-height: 100%;
height: auto;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
从纵向和横向的大量媒体查询开始,您将从这个 sn-p 中获得概念:
...
@media only screen and (min-width: 2049px) and (max-width: 2560px) and (min-height: 1441px) and (max-height: 1600px) {
#hero {
background-image: url(../img/hero/landscape/cover-2560-1600.jpg); /* 8:5 */
}
}
@media only screen and (min-width: 2049px) and (max-width: 2560px) and (min-height: 1601px) and (max-height: 2048px) {
#hero {
background-image: url(../img/hero/landscape/cover-2560-2048.jpg); /* 5:4; */
}
}
@media only screen and (min-width: 2561px) and (min-height: 2049px) {
#hero {
background-image: url(../img/hero/cover-any-max.jpg); /* fallback for ultra high resolutions */
}
}
除了需要做大量工作来为最常用的分辨率创建高质量图像并为每个分辨率编写媒体查询之外,这些查询都无法处理不常见的浏览器尺寸,如果,例如,用户将他的窗口拖得非常宽但又非常短,他得到的只是一个白色背景。
我希望得到有关此问题的提示,因为我在网上找到的大多数响应式图片的报道都不是很有帮助,因为它没有得到我想要的广泛使用。
【问题讨论】:
标签: html css responsive-design