Div显示/隐藏媒体查询 [英] Div show/hide media query

查看:180
本文介绍了Div显示/隐藏媒体查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有在移动宽度上,我才能使用什么代码来显示特定的div?

What code can I use to make a particular div show only if on a mobile width?

我在屏幕顶部有一个100%宽的全格,希望它仅在将设备指定为移动宽度时显示.

I have a 100% width full div at the top of my screen, would like it to only show when the device is specified as a mobile width.

推荐答案

我不确定您所说的移动宽度"是什么.但是在每种情况下,CSS @media都可以用于隐藏屏幕宽度为基础的元素.看一些例子:

I'm not sure, what you mean as the 'mobile width'. But in each case, the CSS @media can be used for hiding elements in the screen width basis. See some example:

<div id="my-content"></div>

...并且:

@media screen and (min-width: 0px) and (max-width: 400px) {
  #my-content { display: block; }  /* show it on small screens */
}

@media screen and (min-width: 401px) and (max-width: 1024px) {
  #my-content { display: none; }   /* hide it elsewhere */
}

一些真正的移动检测是一种困难的编程,而且相当困难.最终查看: http://detectmobilebrowsers.com/或其他类似来源.

Some truly mobile detection is kind of hard programming and rather difficult. Eventually see the: http://detectmobilebrowsers.com/ or other similar sources.

这篇关于Div显示/隐藏媒体查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆