[英]Why my grid doesn't work in Chrome but, does in Firefox Developer Edition?
I have a project that I'm working on and I use CSS grids to style it as I want.我有一个正在处理的项目,我使用 CSS 网格根据需要对其进行样式设置。 The problem is sometimes it works in Chrome and sometimes it doesn't问题是有时它在 Chrome 中工作,有时它不
Look at screenshot and below it is the code:-看截图,下面是代码:-
The screenshots are at the same zoom level and the same pixel ratio, and the same pixel size!屏幕截图的缩放级别和像素比相同,像素大小相同! This is the navigation in Google Chrome made with the grid system这是 Google Chrome 中使用网格系统制作的导航
And this is the navigation in Firefox Developer Edition made with the grid system这是使用网格系统制作的Firefox Developer Edition中的导航
And here is my code这是我的代码
HTML
<!-- START: GRID CONTAINER -->
<div class="l-grid">
<!-- START: RESPONSIVE NAVBAR -->
<nav class="l-navigation" data-screen="mini">
<div class="l-navigation__cart js-miniCartTrigger" data-icon="miniCart">
<a href="#" class="l-navigation--cart--focus"
><i class="fas fa-shopping-cart l-navigation__cart--icon"></i
></a>
</div>
<!-- Make the whole div a hyperlink -->
<!-- Remember to remove this element when using the mini cart because it's clickable even when its beneath it -->
<div
class="l-navigation__logo"
onclick="location.href='http:/\/localhost:5500/index.html'"
>
<i class="fas fa-gem l-navigation__logo--icon"></i>
<h2 class="l-navigation__logo--title">The H</h2>
</div>
<div class="l-navigation__menu" data-menu="miniMenu">
<a href="#" class="l-navigation--menu--focus"
><i class="fas fa-bars l-navigation__menu--icon js-navigationIcon"></i
></a>
<i class="fas fa-times l-navigation__menu--icon u-d-none js-navigationIconCancel"></i
></a>
</div>
<!-- END: RESPONSIVE NAVBAR -->
</nav>
<!-- END: GRID -->
</div>
CSS
for the grid网格的CSS
.l-grid {
display: grid;
height: 100vh;
grid-template-columns: repeat(auto-fit, minmax(100%, 1fr));
grid-auto-rows: 7rem;
gap: 0.3rem;
grid-template-areas: "navigation";
}
CSS
for the navigation用于导航的CSS
.l-navigation {
grid-area: navigation;
background-color: $color-navigation-bar;
border-bottom: 1px solid $color-navigation-border;
display: flex;
justify-content: space-between;
align-content: center;
padding: 2rem;
}
Can you tell me what is wrong here?你能告诉我这里有什么问题吗? And if possible can you tell me how can I make the grid system suitable for mobile-first designing?如果可能,您能告诉我如何使网格系统适合移动优先设计吗?
Thanks谢谢
So, to answer my question所以,回答我的问题
Well, the problem is not something with the code but actually with Google Chrome So I'm keeping it here for others to see and find the answer嗯,问题不在于代码,而在于 Google Chrome 所以我把它留在这里供其他人查看和找到答案
If you restart your computer or remove the cache it works great and it doesn't have anything to do with the code itself如果您重新启动计算机或删除缓存,它会很好用,并且与代码本身没有任何关系
Well, actually if you just resize the window without going to the responsive panel in the inspect element tool in Chrome it works好吧,实际上,如果您只是调整窗口大小而不转到 Chrome 中检查元素工具中的响应面板,则它可以工作
I found the answer for this stupid and silly thing after 2 hours of wasting time here and there我在这里和那里浪费了 2 个小时的时间后,找到了这件愚蠢而愚蠢的事情的答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.