动态 Web 项目 Eclipse 的 XHTML 文件中的 CSS 方式和位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11325461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:27:42  来源:igfitidea点击:

How and where CSS in XHTML file of Dynamic Web Project Eclipse

csseclipsejsfxhtml

提问by user1494328

I'm trying to link css file to xhtml page in several ways but nothing what I did want to work. Here is folders structure of project:

我正在尝试以多种方式将 css 文件链接到 xhtml 页面,但没有任何我想做的工作。这是项目的文件夹结构:

Project
   Java serources
   WebContent
   **index.xhtml**
      META-INF
      WEB-INF
      style
         **style.css**

Now in index.xhtml file I have: <link rel="stylesheet" href="style/style.css" />

现在在 index.xhtml 文件中我有: <link rel="stylesheet" href="style/style.css" />

Can someone tell me what I do wrong?

有人能告诉我我做错了什么吗?

回答by Daniel

Add resourcesfolder under the WebContent

resources在下面添加文件夹WebContent

and inside resourcescreate cssfolder

并在resources创建css文件夹内

then access the files like this

然后像这样访问文件

<h:outputStylesheet library="css" name="myNewStylesFile.css" target="head" />

Here's a tutorial Resources (library) in JSF 2.0

这是JSF 2.0 中的教程资源(库)

回答by dsfg

Put your link tag as I mention below:

把你的链接标签放在我下面提到的:

<link href="style/style.css" rel="stylesheet" type="text/css"/>