我有以下 html 和样式,当它们在页面中定义时应用得很好,但是当我将样式移动到 .css 时它不适用(使用 bootstrap 和 jsp,所以不确定是否适用)。
注意:我在那个 .css 中有其他样式,它们在 .jsp 页面上正确地设置了 html 样式。只是不是这个特殊的 wontStyle 类。
索引.jsp
<body>
<div id="wrapper">
<div class="container">
<div class="row-fluid">
<div class="span2">
<div class="well">
<div class="wontStyle"> <!-- This won't style in .css but will style inside page -->
如果我在页面标记中应用以下内容,它会应用边距和填充(有效)。
<style>
.wontStyle{
margin-top: -9px !important;
padding-bottom: 18px !important;
}
</style>
但是,如果我将样式移动到 mystyle.css,它将不再应用这些样式(不起作用)?
mystyle.css
.wontStyle{
margin-top: -9px !important;
padding-bottom: 18px !important;
}
包含在我的 index.jsp 中
<link href="content/css/mystyle.css" rel="stylesheet">
如何让它应用我的 .css 文件中的样式?
编辑/更新:
问题在于以下 Bootstrap 模式折叠样式缺少 },当放置在折叠下方时会破坏 wontstyle。
.collapse {
.transition(height .15s ease);
position:relative;
overflow:hidden;
height: 0;
&.in {
height: auto;
}
我没有在 .css 的控制台上看到 chrome 中的任何错误。我怎样才能在未来捕捉到类似的东西(css 页面无法加载或中断中点/等等)?
最佳答案
使用 JSP 时,您必须在应用程序的上下文中引用 CSS 文件。例如,您可以使用 <c:url>
来自 JavaServer Pages Standard Tag Library定义您需要的任何 CSS/JS/图像文件的路径。假设您的 CSS 文件位于距离/content/css 中当前位置更远的几个文件夹中,您可以在导入后执行以下操作 <c:url>
来自甲骨文:
<link type="text/css" rel="stylesheet" href="<c:url value='/content/css/mystle.css' />" />
关于html - 来自 .css 文件的样式未应用,但来自本地 .jsp 标记 <style>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17952955/