gpt4 book ai didi

css - 响应式背景图片 css 媒体查询

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

我制作了一些 CSS 来为设备选择合适的图像。但是我不知道为什么它一直在我的 15 英寸视网膜 mac pro 上显示 bg970.png 图像。

<style>
/* default screen, non-retina */
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
body{
background: url("img/bg970.png") no-repeat fixed; }

}

/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}

/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}

/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}

/* iPads (landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}

/* iPads (portrait) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}

/* Desktops and laptops ----------- */
@media only screen
and (min-width : 1224px) {
/* Styles */
body{ background: url("img/bg1224.png") no-repeat fixed; }
}

/* Large screens ----------- */
@media only screen
and (min-width : 1824px) {
/* Styles */
body{ background: url("img/bg1824.png") no-repeat fixed; }
}

/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}
</style>

最佳答案

你的最后一句话是:

/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
body{ background: url("img/bg970.png") no-repeat fixed; }
}

但这似乎适用于任何视网膜设备,包括您的 mac pro。

关于css - 响应式背景图片 css 媒体查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20478594/

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