use*_*370 3 php menu cross-browser responsive-design
我正在开发的网站php with responsive HTML。现在,如果用户在中打开该网站,我想隐藏菜单mobile browser (iOS and Android)。
然后,我如何进行验证,HTML or jQuery以便能够hide menu.尝试找到但未找到任何适当的解决方案。
让我知道是否有人。
谢谢
通过CSS,您可以使用类似以下内容的@ media-queries:
@media screen and (max-width: 1199px) {
.your-navigation{
display:none;
}
}
Run Code Online (Sandbox Code Playgroud)
或者您使用jQuery如下所示:
if($(window).width()<=1199){
$(".your-navigation").hide();
}
Run Code Online (Sandbox Code Playgroud)
但我会接受媒体查询,因为它是一种更优雅,更容易更改的方式!
所以实际上您不是在检查它是移动浏览器还是台式机,但是检查浏览器的宽度完全可以...我想,那就是您想要的...
**编辑**
经过一番思考之后,我只想说一句,可以使用javascript来获取当前的浏览器,但是我不建议您使用它,因为它不是很麻烦,并且在获取所有浏览器等方面会遇到很多麻烦就像我已经说过的,顺其自然!:)
(这是方法的链接)
**编辑2 **
关于您的评论:
检查此链接,它应该正是您想要的
这里的代码,感谢feela
/**
* Determine the mobile operating system.
* This function either returns 'iOS', 'Android' or 'unknown'
*
* @returns {String}
*/
function getMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i ) )
{
return 'iOS';
}
else if( userAgent.match( /Android/i ) )
{
return 'Android';
}
else
{
return 'unknown';
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2226 次 |
| 最近记录: |