猿问

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

问这个问题有点傻,但是......

我为我的简历创建了一个网页,但事实是,当我从计算机浏览时,或者我在 Android 上打开“请求桌面版本”时,它的显示效果很完美,所以我的问题是是否有任何方法可以在 Android 中显示为桌面模式(有或没有)请求桌面版本已打开。


浮云间
浏览 124回答 1
1回答

拉丁的传说

您可以有一个变量来控制您的 css 链接到样式表。因此,您为移动设备设置了一个样式表,为桌面设置了另一个样式表,当该按钮发送到服务器发布/请求时,然后将样式表页面的 css 链接设置为该 CSS 页面。例如:在你的 php 页面上...if(isset($_POST['desktop_version'])){&nbsp; &nbsp; $styleSheet = "desktop.css";&nbsp; &nbsp; $buttonDisplay = "Switch to mobile version";&nbsp; &nbsp; $buttonName = "main";}elseif(isset($_POST['main'])){&nbsp; &nbsp; $styleSheet = "main.css";&nbsp; &nbsp; $buttonDisplay = "Switch to desktop version";&nbsp; &nbsp; $buttonName = "desktop_version";}else{&nbsp; &nbsp; // default version when neither instances have been submit yet&nbsp; &nbsp; $styleSheet = "main.css";&nbsp; &nbsp; $buttonDisplay = "Switch to desktop version";&nbsp; &nbsp; $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&nbsp;//... for the desktop version and when set to desktop it sets the attributes&nbsp;//... for the main version.<form method="post">&nbsp; &nbsp; <button type="submit" name="<?=$buttonName?>" value="<?=$buttonDisplay?>"></form>
随时随地看视频慕课网APP

相关分类

Html5
我要回答