用PHP实现换肤

WBOY
發布: 2016-06-23 14:32:23
原創
1316 人瀏覽過

用PHP其实也可以实现简单的“换肤”,其实就是换CSS(当然不可能做到象asp.net 2.0那样厉害拉),
但有时也可以凑合着使用,先要准备几个CSS
style/default.css
body { font-family: arial, verdana; font-size: small; margin: 0px; }
.box { background: red; }
.box-title { text-align: center; color: white; font-weight: bold; }
.box-content { background: white; font-size: xx-small; padding:10px;}
.menu { margin: 5px; }
.menu-active { margin: 2px; padding:5px; background: black; }
.menu-active a { text-decoration: none; color: white; font-weight: bold; }
.menu-inactive { margin: 2px; padding:5px; background: #ccc; }
.menu-inactive a { text-decoration: none; }

styles/black_and_white.css
body { font-family: arial, verdana; font-size: small; margin: 0px; }
.box { background: #eee; border: 1px solid black; }
.box-title { background: white; text-align: center; font-weight: bold; }
.box-content { background: white; font-size: xx-small; padding:10px;}
.menu { margin: 5px; }
.menu-active { margin: 2px; padding:5px; background: black; }
.menu-active a { text-decoration: none; color: white; font-weight: bold; }
.menu-inactive { margin: 2px; padding:5px; background: #ccc; }
.menu-inactive a { text-decoration: none; }

index.php


$style = "default";
if ( $_GET["style"] )
$style = $_GET["style"];
$files = array( );
$dh = opendir( "styles" );
while( $file = @readdir( $dh ) )
{
if( preg_match( "/[.]css$/", $file ) )
{
$file = preg_replace( "/[.]css$/", "", $file );
$files []= $file;
}
}
?>


















   Important information

Lots of information about important events and
stuff.




Style:




相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!