gpt4 book ai didi

css - 为什么我的 css 媒体查询在内页上不起作用?

转载 作者:行者123 更新时间:2023-11-28 02:21:19 25 4
gpt4 key购买 nike

我正在使用媒体查询设置断点,根据最小和最大屏幕尺寸调整 html 元素的样式。它在我的索引页面上运行完美,但链接到同一样式表并使用共享类的内部页面没有调整。

这是我的一个工作媒体查询,它的作用是将标题 div 折叠到导航菜单中:

@media (max-width: 700px) {
input.navigate { display: none; }
img.googlepic {display: none;}
img.navpic {display: none;}
nav select { display: inline;}
}

这是 index.html 中的相关代码:

<div class="header">

<a href="index.html#pagetop"><input class="navigate" type="button" value="Home"></a>
<a href="demo.html"><input class="navigate" type="button" value="Learn More"></a>
<a href="aboutus.html"><input class="navigate" type="button" value="About Us"></a>
<a href="blog.html"><input class="navigate" type="button" value="RMS News"></a>
<a href="index.html#contactus"><input class="navigate" type="button" value="Contact Us"></a>
<img class="googlepic" src="images/chrome.png">
<img class="navpic" src="images/icx.png">

<nav>
<select>
<option value="" selected="selected">Nav</option>
<a href="index.html#pagetop"><option value="index.html#pagetop">Home</option></a>
<a href="demo.html"><option value="demo.html">Learn More</option></a>
<a href="aboutus.html"><option value="aboutus.html">The RMS Team</option></a>
<a href="blog.html"><option value="blog.html">Blog</option></a>
<a href="index.html#contactus"><option value="index.html#contactus">Contact Us</option></a>
</select>

</nav>
</div>

完全相同的代码被复制并粘贴到我网站的内部页面,但媒体查询不会影响它们。

最佳答案

viewport 的 meta 标签没有在内页上设置。

<meta name="viewport" content = "user-scalable=no, width=device-width">
<meta name="viewport" content="initial-scale=1.0">

关于css - 为什么我的 css 媒体查询在内页上不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48190754/

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