如何在wordpress中仅为桌面视图应用css

时间:2017-12-21 05:49:40

标签: css mobile desktop

我在一个左侧有垂直导航菜单的网站上工作。现在我必须减少导航菜单的宽度,但是当我用桌面视图的普通css减小宽度时它也会影响移动视图,它也会减小移动视图中的宽度。 那么有什么其他解决方案,css应该只适用于桌面视图。它不应该影响移动视图菜单标题。 感谢

3 个答案:

答案 0 :(得分:1)

如何仅在wordpress中为桌面视图应用css。

1.) desktop view media queries. 

@media only screen and (min-width:768px){
   here your code ...
}

@media only screen and (min-width:910px){  <!-- wordpress. twentysixteen theme -->
   here your code ...
}

=============================================== =

如何仅在wordpress中为移动视图应用css。

@media only screen and (max-width:767px){
   here your code ...
}

@media only screen and (max-width:909px){  <!-- wordpress. twentysixteen theme -->
   here your code ...
}

===============================================

/ * saf3 +,chrome1 + * /你有任何问题铬,野生动物园,移动视图和桌面然后在这个媒体下面使用

@media screen and (-webkit-min-device-pixel-ratio:0) {
 #diez  { color: red  }
}

答案 1 :(得分:0)

仅对桌面设备使用css媒体查询 例如:

Desktop
@media only screen and (min-width: 1200px) and (max-width: 1920px) { .classname{width:250px}
}

此处提供桌面和移动媒体查询的链接Media Queries: How to target desktop, tablet and mobile?

答案 2 :(得分:0)

使用媒体查询。确定桌面视图的最小宽度。看起来应该是这样的。

    @media only screen and (min-width: 1000px) {
   /* Css for Desktop goes here like sample below*/
     .desktop-header{height:100px;}
    }

如果您只想更改桌面视图的元素,请记住您需要使用min,这意味着所有宽度等于或超出您选择的像素。 你还需要使用

<meta name="viewport" content="width=device-width, initial-scale=1">

在你的html的头部响应。 *注意除了媒体查询之外,您必须使用一种代理检测,这将根据浏览器查看用户所使用的平台并基于此提供内容,但我不建议使用此方法。