Home > Blockchain >  @media screen and (min-width: 1280px){ does not work even though my resolution is 1920*1080
@media screen and (min-width: 1280px){ does not work even though my resolution is 1920*1080

Time:01-16

The Navigation menu items are not showing for 1920 * 1080

I set display = none for all device widths except >1280

 `@media only screen and (min-width: 100px) and (max-width: 260px) {

  header .navigation {
  display: none;
  }

  @media only screen and (min-width: 260px) and (max-width: 350px) {

  header .navigation {
  display: none;
  }



 @media only screen and (min-width: 370px) and (max-width: 500px) {
  header .navigation {
 display: none;
}


@media only screen and (min-width: 500px) and (max-width: 1280px) {
header .navigation {
display: none;
}

@media only screen and (min-width: 350px) and (max-width: 370px) {

header .navigation {
display: none;
}

@media screen and (min-width: 1280px){

header .navigation{

height:3em;
position: relative;
background:  dark orange ;
width:98em;
top:50;
left:-12em;
font-size:30px;
font-color: dark orange;
font-family: Meow Script;
padding:20px;
}


header .navigation .navigation-items a{

 font-family: Meow Script;
  position: relative;
  background: dark red;
  color: white;
  font-size: 3em;
  font-weight: 500;
  width:100px;
  font-size:20px;
  text-decoration: none;
  margin-left: 15px;
  transition: 0.3s ease;
  left :15em;
  padding: 15px 40px;
  border-radius:150px;
  font-family: Meow Script;
  }

  header .navigation .navigation-items a span{
  border-radius:50px;
  width:100px;
  font-family: Meow Script;
  font-size: 1.2em;
  }

  header .navigation .navigation-items a:before{
   content: '';
   position: absolute; 
   font-family: Meow Script;
   width: 0;
   height: 3px;
   bottom: 0;
   left: 0;
   transition: 0.3s ease;
  }

  header .navigation .navigation-items a:hover:before{
  width: 100%;
  }
  }`

  if I use the same in a different CSS file without media queries I am able to see the navigation menus in my Laptop 1920*  1080 resolution.

Navigation menus showing when CSS used without media Query.Navigation menu not showing when CSS used with media Query for 1920*1080 Laptop

I tried to write media queries such that Navigation menu shows only >1280 px width and not for smaller screen width like mobile and Laptop.

I made display = none for all device widths <1280px.

But the navigation menu is not displaying for 1920*1080 as

well (>1280px width)

CodePudding user response:

You are missing an only on the last mediaQuery.

@media screen and (min-width: 1280px){

Should be

@media only screen and (min-width: 1280px){

CodePudding user response:

Start fixing some errors in your CSS, if you don't know what fix try using an online validator, like this:

https://jigsaw.w3.org/css-validator/#validate_by_input

Maybe the problem is not properly on the media queries but in the output generated by other rules.

Hint about media queries: put all your CSS outside the media Queries and use them only to change the desired features. Pay attention to the order of the media queries, sometime a statement overwrite the one before.

Try this CSS:

header .navigation {
    display: none;
}
header .navigation {
    height: 3em;
    position: relative;
    background: darkorange;
    width: 98em;
    /* top:50;*/ /* this make the object disappear */
    /* left:-12em;*/ /* this make youtr object disappear */
    font-size: 30px;
    color: #000;
    font-family: Meow Script;
    padding: 20px;
}
header .navigation .navigation-items a {
    font-family: Meow Script;
    position: relative;
    background: darkred;
    color: white;
    font-size: 3em;
    font-weight: 500;
    width: 100px;
    font-size: 20px;
    text-decoration: none;
    margin-left: 15px;
    transition: 0.3s ease;
    left : 15em;
    padding: 15px 40px;
    border-radius: 150px;
    font-family: Meow Script;
}
header .navigation .navigation-items a span {
    border-radius: 50px;
    width: 100px;
    font-family: Meow Script;
    font-size: 1.2em;
}
header .navigation .navigation-items a:before {
    content: '';
    position: absolute;
    font-family: Meow Script;
    width: 0;
    height: 3px;
    bottom: 0;
    left: 0;
    transition: 0.3s ease;
}
header .navigation .navigation-items a:hover:before {
    width: 100%;
}
@media screen and (min-width: 1280px) {
header .navigation {
    display: block;
}
}

Working Codepen: https://codepen.io/Davevvave/pen/poZrwZE

  • Related