css - 如何使背景图像响应移动设备
问题描述
我正在使用 HTML 和 CSS 创建一个网站,但是我的背景图像对像移动设备这样的小型设备没有响应,因为我减小了窗口的大小,所以我的图像的 CSS 代码是这样的:
body{
background-image: url(image.jpg);
background-size: cover;
border-image-repeat: no-repeat;
}
解决方案
/* 当浏览器或屏幕尺寸低于 767px 时使用 */
@media only screen and (max-width: 767px) {
body{
background: url(image.jpg)no-repeat;
background-size: cover;
background-position: center;
}
}
推荐阅读
- java - 转换地图
> 到地图 使用流 - python-docx - 在同一级别添加两个段落
- mysql - 如果某些值不存在,MySQL INSERT 多行
- android - 发送 MAKE_CREDENTIAL(0x01) 响应时出现超时问题
- angular - 扩展状态时,如何为共享选择器实现共享操作?
- java - 输入字段的验证
- hyperledger-fabric - 如何在超级账本结构中使用没有 CA 的相互身份验证
- postgresql - Postgresql 相当于 H2 DROP ALL OBJECTS
- spring-security - 在 Spring Security 过滤器链中处理多个自定义过滤器
- unit-testing - 如何从视图中删除“@oidc.login_required”以进行单元测试?