外部CSS中的样式html表不起作用(styling html table in external css doesn't work)

编程入门 行业动态 更新时间:2024-10-14 20:19:50
外部CSS中的样式html表不起作用(styling html table in external css doesn't work)

我有一个包含html元素的jsp文件,它有一个带有特定id的表。 当我添加边框时:1px; 内部样式然后它工作,但当我想使用指定样式的css文件,然后它没有,因此根本没有边框。

jsp文件的相关部分:

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Airline Database</title> <link rel="stylesheet" type="text/css" href="styles/PassengerStyle.css"/> </head> <body> <table id="main" width="1300px"> ... </table> </body> </html>

PassengerStyle.css文件:

#main { border: 1px solid black; }

css文件位于与jsp文件位于同一文件夹中的styles文件夹中。

我错过了什么?

I have a jsp file that holds html elements, it has a table in it with a specific id. When I add the border: 1px; styling internally then it works, but when I want to use a css file that specifies styling, then it doesn't, there's no border at all as a result.

the relevant part of the jsp file:

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Airline Database</title> <link rel="stylesheet" type="text/css" href="styles/PassengerStyle.css"/> </head> <body> <table id="main" width="1300px"> ... </table> </body> </html>

the PassengerStyle.css file:

#main { border: 1px solid black; }

the css file is in the styles folder that is in the same folder as the jsp file.

What did I miss?

最满意答案

它可能找不到样式表,即url是错误的。 您是否尝试导航到“查看源”中的代码认为该文件所在的位置? 那可能与现在不同。

您也可以尝试添加body {background-color:red; 查看该样式表中的任何样式是否适用。

It probably can't find the stylesheet, i.e. the url is wrong. Have you tried navigating to where the code in 'view source' thinks the file is located? That's probably different then where it is.

You can also try adding body { background-color: red; } to see if any styles from that stylesheet apply.

更多推荐

css,jsp,file,文件,px,电脑培训,计算机培训,IT培训"/> <meta name="descriptio

本文发布于:2023-08-06 17:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1452772.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:样式   不起作用   html   CSS   styling

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!