display:none 在移动设备上无法正常工作

display:none not correctly working on mobile

这里有一个 CSS 代码,我想在 PC 视图中隐藏它但在 Phone 视图中可见,我可以在 PC 上实现我的结果,但不能在 Phone,因为 display: none; 正在干扰代码的工作。有人可以检查一下吗?

  /* --------- Game-section-mobile---------*/

* {
  transition: all .155s ease-in-out;
}

.event-link {
  margin: 300px 0 0 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  text-decoration: none;
}

.event-h3 {
  margin-top: 30px;
}

.events {
  display: flex;
  flex-wrap: wrap;
  display: none;
}

.events .shadowbox {
  height: 100vh;
  padding-top: 0;
  background: rgba(0, 0, 0, 0.5);
}

.event {
  text-align: center;
  margin-top: 0;
  min-width: 100px;
  background-repeat: no-repeat;
}

.event  .event-h3 {
  padding-top: 50px;
}

.event {
  background-size: cover;
  background-position: center;
  height: 100vh;
  flex-grow: 1;
  flex-basis: 0;
  text-align: center;
  min-width: 100px;
  background-repeat: no-repeat;
}

.event:hover {
  flex-grow: 2;
}

.events .shadowbox:hover {
  background: rgba(0, 0, 0, 0.76);
}

.event .event-h3,
.event p {
  color: white;
  width: 90%;
  margin: auto;
}

.event:not(:first-of-type) {
  border-left: 1px solid white;
}

.shadowbox img{
  margin-top: 50%;
  height: 200px;
}

@media only screen and (max-width: 775px) {
  .event:last-of-type {
    margin-bottom: 10px;
  }

  .event:hover {
    flex-grow: 1;
  }

  .event:nth-of-type(1) {
    max-width: 100%;
  }

  .event {
    min-width: 300px;
    margin-bottom: 3px;
  }

  .shadowbox img{
    margin-top: 50%;
    height: 150px;
  }
}

@media only screen and (max-width: 775px){
  .events{
    display: block;
  }
}

您对 .events 有第二个媒体查询。因此,当您的屏幕宽度小于 775px 时,您的 .events 将再次显示。在移动视图中就是这种情况。删除或注释掉它,它应该可以工作。

   @media only screen and (max-width: 775px){
  .events{
    display: block;
  }
}