-1
我正在設計一個響應式網頁設計,其中有2個不同的頁眉菜單,例如桌面頁眉和移動頁眉[請參閱:由於菜單內容無法響應不同]。 根據屏幕分辨率調用頭文件。 我的代碼是:根據屏幕大小包含php文件
<style type="text/css">
@media only screen and (min-width: 768px) {
/* tablets and desktop */
.mobile {
display: none
}
}
@media only screen and (max-width: 767px) {
/* phones */
.desktop {
display: none
}
}
@media only screen and (max-width: 767px) and (orientation: portrait) {
/* portrait phones */
.desktop {
display: none
}
}
</style>
<div class="mobile">
<?php
include_once(WWW . 'inc/layout/mobile_header.php');
?>
</div>
<div class="desktop">
<?php
{
include_once(WWW . 'inc/layout/desktop_header.php');
}
?>
</div>
此代碼工作正常,但我已經注意到的是,這兩個文件被加載,文件是隱藏的/取決於屏幕大小顯示。 我想要一個代碼,其中只會根據其屏幕大小加載/執行一個PHP文件。
我需要使用2個不同的標題,因爲兩個標題中的菜單都不同。 –
我個人隱藏了你想要通過css擺脫的元素,或者重新設計它,使它在兩者中都起作用。 如果你被困在你的路上,你將不得不使用JS並通過ajax抓取頭。 – bones