gpt4 book ai didi

css - (CSS) 无法为移动设备调整背景图像大小

转载 作者:可可西里 更新时间:2023-11-01 13:28:31 25 4
gpt4 key购买 nike

  /* Responsive Full Background Image Using CSS
* Tutorial URL: http://sixrevisions.com/css/responsive-background-image/
*/

body {
/* Location of the image */
background-image: url(images/background-photo.jpg);
/* Image is centered vertically and horizontally at all times */
background-position: center center;
/* Image doesn't repeat */
background-repeat: no-repeat;
/* Makes the image fixed in the viewport so that it doesn't move when
the content height is greater than the image height */
background-attachment: fixed;
/* This is what makes the background image rescale based on its container's size */
background-size: cover;
/* Pick a solid background color that will be displayed while the background image is loading */
background-color: #464646;
/* SHORTHAND CSS NOTATION
* background: url(background-photo.jpg) center center cover no-repeat fixed;
*/
min-width: 100%;
max-width: 100%;
min-height: 100%;
max-height: 100%;
}
/* For mobile devices */

@media only all and (max-width: 768px) {
.logo {
/* The file size of this background image is 93% smaller
* to improve page load speed on mobile internet connections */
background-image: url(images/background-photo-mobile-devices.jpg);
height: 300px;
width: 100%;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
}

背景图像在桌面浏览器中显示良好,但当我在我的 iphone 6 plus 或任何其他手机上查看它时,图像无法正确缩放并且被部分截断。谁能帮忙?谢谢。

最佳答案

有两种方法可以在后台工作并使其正常工作:你应该删除开头:

min-width: 100%;
max-width: 100%;
min-height: 100%;
max-height: 100%;

height: 300px;
width: 100%;

通过添加以下代码,另一种支持制作长度或宽度的第一种方法:

background-size: 100% auto;

第二种方式,通过添加以下代码来制作任意尺寸的后橡胶:

background-size: 100% 100%;

谢谢

关于css - (CSS) 无法为移动设备调整背景图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33968607/

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