1 回答

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個(gè)贊
您可以有一個(gè)變量來控制您的 css 鏈接到樣式表。因此,您為移動設(shè)備設(shè)置了一個(gè)樣式表,為桌面設(shè)置了另一個(gè)樣式表,當(dāng)該按鈕發(fā)送到服務(wù)器發(fā)布/請求時(shí),然后將樣式表頁面的 css 鏈接設(shè)置為該 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>
- 1 回答
- 0 關(guān)注
- 195 瀏覽
添加回答
舉報(bào)