您可以有一个变量来控制您的 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>