css不在jsf中工作

时间:2013-08-15 22:26:05

标签: css jsf-2 primefaces

我为Prime-faces创建了css文件,我已经厌倦了但不能正常工作。

这是我的style.css文件

 <!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" dir="rtl">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<style type="text/css">
*{
 padding:0px;
 margin:0px;

}
 body{
background-color:#ffffff;
  }
 .head1{
background-repeat:repeat-x;
background-image: url('images/rd-el_03.png');
height:174px;
 }
 .head2{
background-image: url('images/rd-el_02.png');
width:364px;
height:174px;
margin-left:auto;
margin-right:auto;
background-repeat:no-repeat;
  }
 img{
 border:0;
  }
 .footer1{
   background-image: url('images/rd-el_07.png');
  height:87px;
  background-repeat:repeat-x;   
  }
  .footer2{
  background-image: url('images/rd-el_06.png');
  float:left;
  width:89px;
  height:87px;
  background-repeat:no-repeat;

   }
 .footer3{
   background-image: url('images/rd-el_09.png');
  width:272px;
 height:87px;
 float:right;
 background-repeat:no-repeat;

  }
 </style>
 </head>

 <body>
  <div class="head1">
 <div class="head2"></div>
</div>

 <div class="footer1">
 <a href="http://tl4s.com.sa" title="تصميم منتدى"><div class="footer2"></div></a>
 <div class="footer3"></div>
 </div>



  </body>

 </html>

这个style.css在 网页内容  | - 资源  | -- css | - style.css  :

我已将此代码放在我的xhtml文件中,但没有运气

 <h:head>
  <h:outputStylesheet name="css/styles.css" />
 </h:head>

2 个答案:

答案 0 :(得分:1)

嗯,它看起来不像是一个CSS文件。它是一个HTML / XHTML文件,其中嵌入了CSS代码。删除所有HTML代码和标签内的所有内容,将其放入CSS文件中!那可行。 所以CSS文件看起来像:

---------------------------------- START ------------ ----

.body{
 css code here
}

.property1{
 css code here
}

-------------------------------------------端--- ---------------

其中应该没有别的东西。

答案 1 :(得分:0)

嗨,我遇到了同样的问题。

我首先使用<h:outputStyleSheet>标记解决了这个问题 而且我不知道这是否适合你,因为我使用的是Maven,所以你必须确保你的资源文件夹在里面:

webapp->resources->css->styles.css

并在你<h:head>内放置以下行。 这就是JSF 2引用css文件的方式:

`<h:outputStylesheet library="css" name="styles.css"  /> `

希望这有助于Goodluck