doujingtang6580 2014-07-20 21:39
浏览 45
已采纳

如何将Mobile_Detect.php用于Web表单? [关闭]

I am currently a beginner developing a web form and I am stuck on the mobile support stuff and I came across this php code: Mobile_Detect.php

How do I use it on make my form?

  • 写回答

1条回答 默认 最新

  • doudou3716 2014-07-20 21:55
    关注

    If it is an styling issue there are different ways to archive what you want:

    If you really want to use Mobile_Detect you can do something like this:

    require_once 'Mobile_Detect.php';
    $detect = new Mobile_Detect;
    if($detect->isMobile()){ /* include mobile.css */ } 
    else if($detect->isTablet()){ /* include "tablet.css" */ }
    else { /* include "desktop.css" */ }
    

    But in my mind there is no need to use PHP in this case. You don't need to know WHAT kind of device the user is using since the styling issues are usually related to the screen dimensions. In CSS you can use Media Querys like this:

    @media (min-width:320px) { /* smartphones, portrait iPhone */ }
    @media (min-width:480px) { /* smartphones, landscape iPhone */ }
    @media (min-width:600px) { /* portrait tablets */ }
    @media (min-width:801px) { /* landscape tablets */ }
    @media (min-width:1025px) { /* laptops, and desktops */ }
    @media (min-width:1281px) { /* large laptops and desktops */ }
    

    Inside the querys you can overwrite CSS properties that are only used if the screen dimension is in the given range. A very smart solution I think!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题