css - CSS:即使添加了媒体查询,移动设备上的 div 仍以与桌面相同的宽度显示
问题描述
这个真的很奇怪 我在这个网站上有一个英雄区域(https://dev-acupuncture.pantheonsite.io/),它是两列(div),在桌面上的宽度为 50%,在移动设备上应该为 100%。但是,当我在移动设备上查看它时,即使我设置了媒体查询以使其为 100%,div 的宽度仍为 50%。像这样:
.hero-left, .hero-right { height: 500px; width: 50%; margin: 0; }
@media screen and (max-width: 1024px) {
.hero-left, .hero-right { width: 100%; }
}
我检查了控制台,它看到了查询,但它似乎不想尊重它。所以一切仍然是50%。真的很困惑为什么会出现这种情况。这是我针对该区域的 HTML。
<section class="hero">
<div class="hero-left" data-parallax="scroll" data-position-y="15px" data-image-src="<?php echo get_template_directory_uri(); ?>/img/hero.jpg">
<div class="hero-content">
<p>Text goes here.</p>
</div>
</div>
<div class="hero-right">
<div class="hero-right-top" data-parallax="scroll" data-position-y="15px" data-image-src="<?php echo get_template_directory_uri(); ?>/img/hero2.jpg">
<div class="hero-content">
<p>Text goes here.</p>
</div>
</div>
<div class="hero-right-bottom" data-parallax="scroll" data-position-y="15px" data-image-src="<?php echo get_template_directory_uri(); ?>/img/hero3.jpg">
<div class="hero-content">
<p>Text goes here.</p>
</div>
</div>
</section>
解决方案
也许如果为小型设备制作媒体查询
推荐阅读
- php - Laravel 5.7、php curl 和 WordPress 的连接问题
- sql - 在雪花中解析 JSON
- python - 如何在networkx可视化中为不同的节点集设置不同的标签选项?
- javascript - 如何使用 for 循环将 javascript 数组的元素打印到网页?
- r - 将纬度经度范围映射到R中的坐标值的简单方法?
- perl - Perl 脚本文件手动运行,但不在 crontab 中
- java - 外键在删除时失败,因为 Hibernate 没有首先删除关联
- macos - GDB 在 macOS Catalina 上冻结
- kubernetes - 如何在 minikube 中安装 Cassandra
- javascript - Jquery循环而类不存在