gpt4 book ai didi

html - 在 HTML 中包含 CSS 文件或 CSS 样式

转载 作者:行者123 更新时间:2023-11-28 17:58:01 24 4
gpt4 key购买 nike

如果我直接在 html 代码中使用 css 代码,它就可以工作。如果我通过标签链接 html 内部的 css 文件来使用,它是行不通的。但是我尝试使用 ffox viewsource 和 link for css redirects to the perfect CSS .请在这个案例中启发我。提前致谢。

CSS(POStyle.css) 文件包含在 HTML 中:

 <link href="$contextpath/css/yes/POStyle.css" rel="stylesheet" type="text/css"></link>

POStyle.css 有

.popupCSS td, .popupCSS td
{
border:1px solid black;
background-color:#EAF2FB;
color : red;
}

直接在 html 中使用 CSS:

<style type="text/css">
.popupCSS td, .popupCSS td
{
border:1px solid black;
background-color:#EAF2FB;
color : red;
}
</style>

最佳答案

使用时:

<link href="$contextpath/css/yes/POStyle.css" rel="stylesheet" type="text/css"></link>

浏览器使用字符串文字 $contextpath/css/yes/POStyle.css请求 CSS 文件。没有像您在 JSP 文件或其他一些 View 技术中期望的那样发生替换。

您必须使用文件的绝对或相对 URL:

相对

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

绝对

<link href="http:/www.mydomain.com/context/css/yes/POStyle.css" rel="stylesheet" type="text/css"></link>

关于html - 在 HTML 中包含 CSS 文件或 CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21018050/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com