2015-01-12 99 views
-1

我有一個問題,我有一個網頁,有它自己的CSS文件,我包括,使用PHP包含有兩個CSS文件

include $_SERVER[DOCUMENT_ROOT].'path/file.php'; 

到包括有它自己的css文件中的一面旗幟,但他們分享類似的類,有沒有辦法阻止兩個css文件互相泄漏?

編輯:

好了,所以對我的問題詳細說明,因爲我知道,這是很模糊的,我所要做的就是讓頁面的用戶訪問,這樣一個位置:

<?php include $_SERVER['DOCUMENT_ROOT'].'/aaron/portfolio/banner.php'; ?><!doctype html><html> 
 
\t <head> 
 
\t \t <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> 
 
\t \t <meta content="utf-8" http-equiv="encoding"> 
 
\t \t <link rel="shortcut icon" type="image/ico" href="/wyeweb/img/wyelearn.ico"/> 
 
\t \t <link rel="stylesheet" type="text/css" href="/wyeweb/css/bootstrip.css" /> 
 
\t \t <link rel="stylesheet" type="text/css" href="/wyeweb/css/otherCss.css" /> 
 
\t \t <script src="/wyeweb/js/jquery.js" type="text/javascript"></script> 
 
\t \t <script type="text/javascript" src="/wyeweb/js/bootstrip.js"></script> 
 
\t \t <script src="/wyeweb/js/CSS3_Media.js" type="text/javascript"></script> 
 
\t \t <script src="/wyeweb/js/respond_min.js" type="text/javascript"></script> 
 
\t \t <title> 
 
\t \t \t | Home 
 
\t \t </title> 
 
\t </head> 
 
\t <body> 
 
\t \t <div class="container col-md-offset-3"> 
 
\t \t \t <div class="container col-md-8"><a href="/wyeweb/index.php"><img class="logo-size" src="img/wyeLogo.jpg" alt="Logo"></a></div><!--Logo--> 
 
\t \t \t <div class="col-md-4 address"> 
 
     <a href="http://www.facebook.com/..."> 
 
      <img src="/wyeweb/img/face.jpg" alt="facebook"> 
 
     </a> 
 
     <a href="http://www.twitter.com/..."> 
 
      <img src="/wyeweb/img/twit.jpg" alt="twitter"> 
 
     </a> 
 
     <a href="http://www.linkedin.com/company/..."> 
 
      <img src="/wyeweb/img/link.jpg" alt="linkedin"> 
 
     </a> 
 
     <br/><br/> 
 
     <a href="..."> 
 
      ...<br/>...<br/>...<br/>... 
 
     </a> 
 
     </div><!--address with link to gmaps--> 
 
\t \t </div>...

要調用CSS文件的頂部,但頁面會忽略這些文件並調用從CSS文件中的所有類在這裏所包含的頁面的頂部:

<?php 
 
     $output = 'AN Web Design | %title%'; 
 
     
 
     if($_SERVER['REQUEST_URI'] == '/aaron/portfolio/wyeweb/') 
 
     { 
 
     $output = str_replace('%title%', 'Wyelearn', $output); 
 
     } 
 
     elseif($_SERVER['REQUEST_URI'] == '/aaron/portfolio/portal/') 
 
     { 
 
     $output = str_replace('%title%', 'Concept', $output); 
 
     } 
 
     //elseif($_SERVER['REQUEST_URI'] == '/aaron/prtf.php') 
 
     //{ 
 
     // $output = str_replace('%title%', 'Portfolio', $output); 
 
     //} 
 
     else 
 
     { 
 
     $output = str_replace('%title%', 'View', $output); 
 
     } 
 
    ?> 
 
<!DOCTYPE html PUBLIC 「-//W3C//DTD XHTML 1.0 Transitional//EN」 「http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd」> 
 

 
<html> 
 
\t <head> 
 
\t \t <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> 
 
\t \t <meta content="utf-8" http-equiv="encoding"> 
 
\t \t <title><?php echo $output ?></title> 
 
\t \t <link rel="shortcut icon" type="image/png" href="/aaron/IMG/r1ico.jpg" /> 
 
\t \t <link rel="stylesheet" type="text/css" href="/aaron/css/bootstrap.css" /> 
 
\t \t <link rel="stylesheet" type="text/css" href="/aaron/css/strap_overwrite.css" /> 
 
\t \t <script src="/aaron/js/jquery.js"></script> 
 
\t \t <script src="/aaron/js/bootstrap.js" type="text/javascript"></script> 
 
\t \t <script src="/aaron/js/CSS3_Media.js" type="text/javascript"></script> 
 
\t \t <script src="/aaron/js/respond_min.js" type="text/javascript"></script> 
 
\t \t 
 
\t </head> 
 
\t <body> 
 
\t \t <div class="banner"> 
 
\t \t \t <div> 
 
\t \t \t \t <nav class="navbar navbar-default" role="navigation"> 
 
\t \t \t \t \t <div> 
 
\t \t \t \t \t \t <div class=" container"> 
 
\t \t \t \t \t \t <div class="navbar-header"> 
 
\t \t \t \t \t \t \t <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
 
\t \t \t \t \t \t \t \t <span class="sr-only">Toggle Nav Bar</span> 
 
\t \t \t \t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t </button> 
 
\t \t \t \t \t \t \t <a class="navbar-brand" href="index.php">AN Web Design</a>...

所以我想要做的就是讓頁面的用戶訪問忽略所謂的文件在上述頁面的頂部,只使用那些從主網頁。有沒有辦法做到這一點?

+0

如果他們有'共享相同那麼CSS需要包含2次呢? – Umair

回答

1

也許你可以在一個div包裹banner.php文件

<div class="thebanner"></div> 

然後在每一項類似類的前面加上.thebanner像這樣:

.thebanner .title 
{ 
    ... 
} 

.thebanner .content 
{ 
    ... 
} 
+0

我會試試,謝謝。 – user2992459