如何向 Vaadin/Maven 项目添加 css?
SO 中存在一个问题,关于如何将 css 添加到瓦丁项目。提示是在 /WEB-INF/VAADIN/themes/
位置添加 css。
我的问题是,Vaadin 项目通常在 WebContent
下有 WEB-INF 文件夹,现在在 Maven 上,类似的文件夹位于 webapp
下。这似乎导致我的 css 更改没有生效。
另外,是否需要将自定义 css 与原始 css 放在相同的子结构中?我想修改 table
css,但不知道 css 是否需要位于特定路径中。
那么如何添加表格的 css 以便表格也发生变化,而不仅仅是代码正确构建? :)
更新 1:我可以使用 Firebug 得到以下模板,但这是我在浏览器中得到的最接近的东西。
<链接 rel="stylesheet" type="text/css" href="/html/VAADIN/themes/mytheme/styles.css" >
< html>
<头>
<标题> < /标题>
< /头>
< body onload="javascript:location.replace('/c')" >
< !--下面的数字用于填充空间,以便在 IE 中正常工作。 请参阅 http://support.microsoft.com/default.aspx ?scid=kb;en-us;Q294807 了解更多 关于为什么这是必要的信息。
12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890123456789012345678901234567890
-->
< /正文>
< /html>
< /链接>
There exists a question at SO about how to add css to Vaadin project. The tip there was to add css at /WEB-INF/VAADIN/themes/
location.
My problem is that Vaadin projects normally have WEB-INF folder under WebContent
and now on Maven the similar folder is under webapp
. This seems to be causing that my css changes do not take effect.
Also, is it necessary to have the custom css in same sub-structure as the original css? I want to modify table
css and don't know if the css needs to be in a specific path.
So how to add the css for table so that also the table is changed, not just that the code builds correctly? :)
Update 1: I could get the following tempalate out with Firebug, but this is closest thing what I get to browser.
< link rel="stylesheet" type="text/css" href="/html/VAADIN/themes/mytheme/styles.css" >
< html >
< head >
< title > < /title >
< /head >< body onload="javascript:location.replace('/c')" >
< !--The numbers below are used to fill up space so that this works properly in IE.
See http://support.microsoft.com/default.aspx?scid=kb;en-us;Q294807 for more
information on why this is necessary.
12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890123456789012345678901234567890
-- >
< /body >
< /html >
< /link >
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会将 styles.css 文件放在
src/main/webapp/VAADIN/themes/[yourtheme]/
文件夹中,并配置 Maven 复制src/main/webapp
中的所有内容代码> 进入您的 WEB-INF。这样,您的 .css 文件将最终位于WEB-INF/VAADIN/themes/[yourtheme]/
中。强烈建议从主题继承,而不是尝试覆盖默认主题的行为。
然后,您需要在应用程序中指定主题名称
,并使 .css 文件继承主题的 css(runo、reindeer,...)。
我最近使用 Maven 发布了一个示例 Vaadin 应用程序,可以通过 这个地址。它的目的是在 GAE 上工作,但你可以从 SVN 上查看它并看看我做了什么:
You will probably put your styles.css file in the
src/main/webapp/VAADIN/themes/[yourtheme]/
folder and configure Maven to copy everything insrc/main/webapp
into your WEB-INF. This way your .css file will end up inWEB-INF/VAADIN/themes/[yourtheme]/
.It is strongly recommended to inherit from a theme rather than trying to override the behavior of a default theme.
Then you need to specify your theme name in the application
and make your .css file inherit from a theme's css (runo, reindeer, ...).
I have recently put up a sample Vaadin application using Maven which is accessible at this address. It is aimed to work on GAE, but you can check it out from SVN and have a look at what I have done:
只需一点点改变:
将您的文件夹放在 src/main/resources/VAADIN/themes/ 而不是 src/main/webapp/VAADIN/themes/
我希望它对您有用,就像对我们有用一样
问候 Éric
编辑:这里一个有用的链接:在 Jetty 上部署 Maven Web 项目
Just a little change :
put your folder in src/main/resources/VAADIN/themes/ instead of src/main/webapp/VAADIN/themes/
I hope it will work for you as it worked for us
Regards Éric
edit : Here an useful link : Deploying a Maven web project on Jetty