html - @media 图像无法在缩小的屏幕上加载
问题描述
我有一个与我之前的问题类似的问题。当我减小到 975px 以下时,我的图片应该更改为不同的 jpg,当我减小屏幕尺寸时,它似乎可以在本地工作,但是当我在线查看时,新图片不显示。
由于之前发生过这种情况,我先玩了几个小时,因为害怕看起来很愚蠢,但我现在放弃了,如果有人能提供帮助,我会忍住下巴:)
HTML:
<!-- load this image on big screen -->
<div class=" jumbotron jumbotron-fluid jumbotronbrejos hideformob">
<div class="container-fluid relspan">
<img class="brejosimg" src="resources\images\brejosHouse.jpg">
<div class="jumbospan">
<h4 id="fontI">Albufeira, Algarve Portugal</h4>
</div>
</div>
</div>
<!-- load this image on smaller screens -->
<div class="container-fluid navpad">
<div class="row">
<div class="farmhouseimg farmhouse"></div>
</div>
</div> <!-- end of container -->
CSS:
/* on screens that are less than 975px */
.farmhouseimg {
background-image: url("../images/farmhouse.jpg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
margin-left:0px;
margin-right: 0px;
width:100%;
display: none;
min-height: 600px;
}
.farmhouse {
margin-bottom: 30px;
min-height: 600px;
width:100%
}
@media only screen and (max-width: 975px) {
.farmhouseimg {
display: block;
}
}
.hideformob {
display: block;
}
@media only screen and (max-width: 975px) {
.hideformob {
display: none;
}
}
解决方案
推荐阅读
- mysql - 将数据从 MySQL 加载到 HDFS 时 Sqoop 导入错误
- spring-boot - Spring Aspect - 如何识别哪个 Pointcut 触发了函数
- c# - 使用 Datatable 和 MVVM 的 WPF 示例
- json - 我无法在 shell 中使用 jq 从 JSON 文件中获取 Key 属性值
- android - 如何更改字符串显示
- c# - ASP.NET Core Hosted 和 Server-Side Blazor 之间有什么区别,真的吗?
- windows - 我可以在 WebStorm 中打开多个终端窗口吗?如何打开?
- python-3.x - 如何修复“函数调用中缺少强制关键字参数‘size’”pylint(missing-kwoa) E1125
- angular - 以角度显示 SQL 表结果
- c# - 防止 API 中断更改