2013-01-23 39 views
0

我工作的一個Joomla!模板,我有我的索引和我的template.css的Joomla只加載CSS模板的某些部分

當我離開所有的設計在CSS中似乎只加載有關CSS類的部分,並沒有做任何其他的事情,所以最終我必須寫入所有其他東西到索引這是愚蠢的,因爲我不應該。

例如這是我的index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" > 
<head> 
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/posgradostemplate/css/template.css" type="text/css" /> 
<jdoc:include type="head" /> 
</head> 
<body> 
<div id="wrapper"> 
    <div id="content"> 
     <div class="mainmenu"> 
      <jdoc:include type="modules" name="mainmenu" />   
     </div> 
    </div> 
</div> 
</body> 
</html> 

但作爲預期,沒有背景顯示的包裝和內容不規矩我想要的代碼。這是我的css文件:

html { 

/* IE10 Consumer Preview */ 
background-image: -ms-linear-gradient(top, #E6E6E6 0%, #858585 100%); 

/* Mozilla Firefox */ 
background-image: -moz-linear-gradient(top, #E6E6E6 0%, #858585 100%); 

/* Opera */ 
background-image: -o-linear-gradient(top, #E6E6E6 0%, #858585 100%); 

/* Webkit (Safari/Chrome 10) */ 
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #E6E6E6), color-stop(1, #858585)); 

/* Webkit (Chrome 11+) */ 
background-image: -webkit-linear-gradient(top, #E6E6E6 0%, #858585 100%); 

/* W3C Markup, IE10 Release Preview */ 
background-image: linear-gradient(to bottom, #E6E6E6 0%, #858585 100%); 
margin: 0; 
    padding: 0; 
    border: 0; 
} 

html, body { 
    height: 100%; 
    -webkit-box-sizing: border-box; 
    -moz-box-sizing: border-box; 
    box-sizing: border-box; 
} 

body { 
    margin: 0; 
} 


.mainmenu ul { 
    font-family: Arial, Verdana; 
    font-size: 12px; 
    margin: 0; 
    padding: 0; 
    list-style: none; 
} 
.mainmenu ul li { 
    display: block; 
    position: relative; 
    float: left; 
} 
.mainmenu li ul { 
    display: none; 
} 
.mainmenu ul li a { 
    display: block; 
    text-decoration: none; 
    color: #ffffff; 
    border-top: 1px solid #000000; 
    padding: 5px 15px 5px 15px; 
    background: #000000; 
    margin-left: 1px; 
    white-space: nowrap; 
} 
.mainmenu li:hover li a:hover { 
    background: #FFFF00; 
    color: #FF0000; 
} 
.mainmenu ul li a:hover { 
    background: #000000; 
    color: #FFFF00; 
} 
.mainmenu li:hover ul { 
    display: block; 
    position: absolute; 
} 
.mainmenu li:hover li { 
    background: #FFFF00; 
    float: none; 
    font-size: 11px; 
    color : #000000; 
} 
.mainmenu li:hover a { 
    background: #FFFF00; 
    color : #000000; 
} 


#wrapper{ 
    width: 100%; 
    text-align: center; 
} 

#content{ 
    display: inline-block; 

} 

除了mainmenu以外的一切都不工作,因爲css告訴它。我認爲它沒有被正確加載,我希望它被急切地加載,這樣一切都在腦海中。現在它只有在索引中添加CSS代碼時纔有效,它不應該那樣。建議?

+0

您是否安裝Firebug的或類似的工具來查看被加載CSS是什麼? 通常對我來說css不加載意味着我在加載停止的文件中有一個錯字。還要小心隱藏的字符。 – Elin

回答

0

嘗試使用加載CSS文件中的以下內容:

$document = JFactory::getDocument(); 
$document->addStyleSheet(JURI::root() . "templates/posgradostemplate/css/template.css");