简体   繁体   English

为什么我的 CSS styles 没有应用于笔记本电脑媒体查询?

[英]Why arent my CSS styles being applied to on laptop media query?

My CSS styles arent being applied to my laptop size media query.我的 CSS styles 没有应用于我的笔记本电脑大小的媒体查询。 I tried using a min and max width with no luck.我尝试使用最小和最大宽度但没有运气。 Im looking to mimic this layout:我想模仿这种布局:

https://www.freshworks.com/crm/features/ https://www.freshworks.com/crm/features/

 @media screen and (min-width: 960px) and (max-width:1199px){.grid-container { display: grid; grid-template-columns: repeat(3, 30vw); /* grid-template-rows: 430px 250px; */ grid-template-rows: auto auto; padding: 0px; margin: 50px 0px 50px 0px; }.featureLeft{ position: relative; right: -30px; }.featureRight{ position: relative; left: 50px; }.marginBottom{ position: relative; bottom: 30px; }.features{ width:400px } p{ font-size: 16px; } h1{ font-size: 25px; } h2{ word-wrap: break-word; font-size: 1.125rem; }.grid-container>div { text-align: left; padding: 30px }.container { width: 90%; margin-left: 10px; }.the-feed { grid-area: 1 / 1 / 3; margin-left: 160px; }.feed-image{ height: 305px; margin-top: 50px; width: 200px; position: relative; right: 30px } } /* desktop styles */ @media screen and (min-width: 1200px){.grid-container { display: grid; grid-template-columns: repeat(3, 30vw); /* grid-template-rows: 430px 250px; */ grid-template-rows: auto auto; padding: 0px; margin: 50px 0px 50px 0px; }.featureLeft{ position: relative; right: -30px; }.featureRight{ position: relative; left: 50px; }.marginBottom{ position: relative; bottom: 30px; }.features{ width:400px } p{ font-size: 16px; } h1{ font-size: 25px; } h2{ word-wrap: break-word; font-size: 1.125rem; }.grid-container>div { text-align: left; padding: 30px }.container { width: 1300px; margin-left: 20px; }.the-feed { grid-area: 1 / 1 / 3; margin-left: 160px; }.feed-image{ height: 305px; margin-top: 50px; width: 200px; position: relative; right: 30px } }

Ive got the grid working but it seems to spaced on my desktop, when I move the features closer together, laptop size messes up even though I have seperate media queries我已经让网格工作了,但它似乎在我的桌面上隔开,当我将这些功能靠得更近时,即使我有单独的媒体查询,笔记本电脑的尺寸也会变得混乱

heres my codepen: https://codepen.io/shuibcodes/pen/xxqWajO这是我的代码笔: https://codepen.io/shuibcodes/pen/xxqWajO

Actually your laptop media query styles are applied but they not seem to be styled correctly for the reference you shared.实际上,您的笔记本电脑媒体查询 styles 已应用,但它们的样式似乎不适合您共享的参考。

Check these fixes.检查这些修复。

@media screen and (min-width: 960px) and (max-width: 1199px) {
  .grid-container {
    display: grid;
    grid-template-columns: repeat(2, 50vw); //Changed
    
    ....

   .the-feed {
    grid-column: 1/-1; //Changed
  }

Full example: https://codepen.io/AravinthAro/pen/gOmeqjJ完整示例: https://codepen.io/AravinthAro/pen/gOmeqjJ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM