简体   繁体   English

如何在 Wicket 9.8.0 中实现 CSS

[英]How to implement CSS into Wicket 9.8.0

Despite using the <wicket:link> tags around my <link> tags my CSS is still not being applied to my HTML even with some attempts to move the css file into my webapp folder (Currently its in the same package as my wicket files).尽管在我的<link> <wicket:link>标签,但我的 CSS 仍然没有应用到我的 HTML 即使尝试将 css 文件移动到我的 webapp 文件夹中(目前它与我的 wicket 文件在同一个 package 中) .

My current HTML file:我当前的 HTML 文件:

<!DOCTYPE html>
<html lang="en">
<head>
    <wicket:link>
        <link rel="stylesheet" href="style.css" type="text/css">
    </wicket:link>
</head>
<header id="masthead" class="site-header" style="background-color: rgb(36, 0, 72);">

</header>
<body>
<div>

</div>
<span wicket:id="welcome">WELCOME</span>
<h1>testing</h1>
</body>
</html>

My Current CSS file (simple just for testing):我当前的 CSS 文件(仅用于测试):

h1 {
    font-size: 100px;
}
.site-header {
    display: flex;
    align-items: center;
    padding: 0 30px;
    z-index: 10002;
}

header {
    position: fixed;
    width: 100%;
    top: 0;
    height: 95px;
}

<wicket:link> helps to construct a correct url to style.css when it is in the classpath, next to MyPage.html file. <wicket:link>有助于构建一个正确的 url 到style.css当它在类路径中时,在 MyPage.html 文件旁边。 Ie if style.css is in src/main/resources/com/example/pages folder and MyPage.java is in com.example.pages package.即,如果style.css在 src/main/resources/com/example/pages 文件夹中,而MyPage.javacom.example.pages package 中。

Usually CSS files are put in src/main/webapp folder.通常 CSS 个文件放在src/main/webapp文件夹中。 In this case you don't need to wrap it with <wicket:link> .在这种情况下,您不需要用<wicket:link>包装它。 You can read more about it in the user guide .您可以在用户指南中阅读更多相关信息。

The best way to start with Wicket is by using the quickstart application !开始使用 Wicket 的最佳方式是使用快速启动应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM