JSP 中的内联 CSS 样式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26394230/
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
Inline CSS styles in JSP
提问by user3861559
I am trying to render THISin JSP. I want the styling to be inline right now as I am in the early stages of development .
我正在尝试在 JSP 中呈现THIS。我希望样式现在是内联的,因为我处于开发的早期阶段。
My JSP code is
我的 JSP 代码是
<%
%><%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false" %><%
%><%
<style type="text/css">
.line {
width:70%;
}
.line:after {
content:'';
position: absolute;
border-style: solid;
border-width: 15px 15px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
top: 8px;
left: 45%;
}
.line:before {
content:'';
position: absolute;
border-style: solid;
border-width: 15px 15px 0;
border-color: #7F7F7F transparent;
display: block;
width: 0;
z-index: 1;
top: 9px;
left: 45%;
}
</style>
<%@include file="/apps//global.jsp"%>
<hr class="line">
%>
I am certain the css styling is fince as it renders correctly in fiddle.
我确信 css 样式很好,因为它在小提琴中正确呈现。
Is there a way I can fix this? Any help is much appreciated. Thanks much.
有没有办法解决这个问题?任何帮助深表感谢。非常感谢。
回答by Shivani Shanishchara
for each and every section define classes for css and include it in using
为每个部分定义 css 类并将其包含在使用中
回答by himani1349
No you cannot put CSS directly into the JSP, it doesn't work that way. You need to import a css file into the jsp using jstl core tags. Refer to this linkon how to do it step by step, it describes how to add css to a jsp in a Spring MVC project.
不,您不能将 CSS 直接放入 JSP,它不能那样工作。您需要使用 jstl 核心标签将 css 文件导入到 jsp 中。请参阅此链接以了解如何逐步执行此操作,它描述了如何将 css 添加到 Spring MVC 项目中的 jsp。