为了账号安全,请及时绑定邮箱和手机立即绑定

如何让网页强制显示桌面版本

如何让网页强制显示桌面版本

浮云间 2023-10-30 15:21:36
问这个问题有点傻,但是......我为我的简历创建了一个网页,但事实是,当我从计算机浏览时,或者我在 Android 上打开“请求桌面版本”时,它的显示效果很完美,所以我的问题是是否有任何方法可以在 Android 中显示为桌面模式(有或没有)请求桌面版本已打开。
查看完整描述

1 回答

?
拉丁的传说

TA贡献1789条经验 获得超8个赞

您可以有一个变量来控制您的 css 链接到样式表。因此,您为移动设备设置了一个样式表,为桌面设置了另一个样式表,当该按钮发送到服务器发布/请求时,然后将样式表页面的 css 链接设置为该 CSS 页面。


例如:


在你的 php 页面上...


if(isset($_POST['desktop_version'])){

    $styleSheet = "desktop.css";

    $buttonDisplay = "Switch to mobile version";

    $buttonName = "main";

}elseif(isset($_POST['main'])){

    $styleSheet = "main.css";

    $buttonDisplay = "Switch to desktop version";

    $buttonName = "desktop_version";

}else{

    // default version when neither instances have been submit yet

    $styleSheet = "main.css";

    $buttonDisplay = "Switch to desktop version";

    $buttonName = "desktop_version";

}


//... in your html head

<link rel="stylesheet" type="text/css" href="<?=$styleSheet?>">


//... in your html body your buttons value is set to the opposite of the set sheet it is using

//... when the style sheet is set to main, the button displays the attributes 

//... for the desktop version and when set to desktop it sets the attributes 

//... for the main version.

<form method="post">

    <button type="submit" name="<?=$buttonName?>" value="<?=$buttonDisplay?>">

</form>


查看完整回答
反对 回复 2023-10-30
  • 1 回答
  • 0 关注
  • 61 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信