繁体   English   中英

@media screen and (min-width: 1280px){ 即使我的分辨率是 1920*1080 也不起作用

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

1920 * 1080 不显示导航菜单项

我为除 >1280 之外的所有设备宽度设置 display = none

 `@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.

在没有媒体查询的情况下使用 CSS 时显示的导航菜单。 当 CSS 与 1920*1080 笔记本电脑的媒体查询一起使用时,导航菜单不显示

我尝试编写媒体查询,使导航菜单仅显示 >1280 像素的宽度,而不显示较小的屏幕宽度,如移动设备和笔记本电脑。

我为所有设备宽度 <1280px 设置了 display = none。

但是导航菜单不显示 1920*1080 为

很好(>1280px 宽度)

only在最后一个mediaQuery上缺少一个。

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

应该

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

开始修复您的 CSS 中的一些错误,如果您不知道如何修复,请尝试使用在线验证器,如下所示:

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

也许问题不在媒体查询上,而在其他规则生成的 output 上。

关于媒体查询的提示:将所有 CSS 放在媒体查询之外,仅使用它们来更改所需的功能。 注意媒体查询的顺序,有时一条语句会覆盖之前的语句。

试试这个 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;
}
}

工作代码笔: https://codepen.io/Davevvave/pen/poZrwZE

暂无
暂无

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

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