7
7
7GIT2020-11-10 09:28:34
css
7GIT, 2020-11-10 09:28:34

What is the correct media query for display:none?

It is necessary to hide the block on the ExtraSmall (cell-es) and Small (cell-s) screens.
If I add cell-es cell-s classes to the html markup, then everything works, but I would like to know:
1. How correct am I doing everything?
2. How to make a request correctly for one class.

HTML: Markup

<!--BEGIN [@Header/Top] Top-->
<div class="row__top">
  <div class="cell cell__top cell-s">
    <div class="main__top">
      <div class="top__item">left</div>
      <div class="top__item top__item--full">
        mid
      </div>
      <div class="top__item mr-0">right</div>
    </div>
  </div>
</div>
<!--END [@Header/Top] Top-->

CSS: Basic Styles

.row__top {
  background: #ffde40;
}

.cell {
  
}

.cell__top {
  box-sizing: border-box;
  margin: 0 auto;
  max-width: 1280px;
}

.main__top {
  display: flex;
  height: 56px;
  align-items: center;
}

.top__item--full {
  flex: auto;
  justify-content: center;
}

.top__item {
  display: flex;
  margin-right: 16px;
}


CSS: Media queries

/** BEGIN [@Media] **/
@media (max-width: 319px) {
  .cell {
    padding: 0 8px;
  }
  .cell-es {
    display: none;
  }
}

@media (min-width: 320px) and (max-width: 543px) {
  .cell {
    padding: 0 16px;
  }
  .cell-s {
    display: none;
  }
}

@media (min-width: 544px) and (max-width: 767px) {
  .cell {
    padding: 0 24px;
  }
  .cell-m {
    display: none;
  }
}

@media (min-width: 768px) and (max-width: 1011px) {
  .cell {
    padding: 0 32px;
  }
  .cell-l {
    display: none;
  }
}

@media (min-width: 1012px) {
  .cell {
    padding: 0 48px;
  }
  .cell-el {
    display: none;
  }
}
/** END [@Media] **/


Demo: https://jsfiddle.net/AIDimov/onmqk74y/1/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Khudiyev, 2020-11-10
@7GIT

/** BEGIN [@Media] **/
@media (max-width: 319px) {
  .cell {
    padding: 0 8px;
  }
  .cell-es {
    display: none;
  }
}

@mediagenia  (max-width: 543px) {
  .cell {
    padding: 0 16px;
  }
  .cell-s {
    display: none;
  }
}

You can do this and then you will not need to assign two classes to hide the element at two sizes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question