没有响应CSS网媒体查询

问题描述 投票:1回答:1

我与电网的工作,由于某种原因,在媒体查询中使用max-width似乎什么也不做。下面的代码:

码:

body {
  color: #fff;
  text-align: center;
}

#content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(100px, auto);
  grid-gap: 1rem;
  grid-template-areas: 'header header header header' 'block_1 block_1 block_2 block_2'
}

@media only screen and (max-width:700px) {
  #content {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(100px, auto);
    grid-gap: 1rem;
    grid-template-areas: 'header' 'block_1' 'block_2'
  }
}

#content>* {
  background-color: #fff;
  border: 1px solid black;
}

.header {
  grid-area: header;
  height: 150px;
}

.block_1 {
  grid-area: block_1;
  height: 150px;
}

.block_2 {
  grid-area: block_2;
  height: 150px;
}
<!doctype html>

<html>

<head>
  <link rel="stylesheet" type="text/css" href="master.css">
</head>

<body>
  <div id='content'>
    <div class='header'>Header</div>
    <div class='block_1'>Header</div>
    <div class='block_2'>Header</div>
  </div>
</body>

</html>

我期望2个类在699px和下方在彼此顶部堆叠。然而,他们似乎并不想这样做。

css css-grid
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.