CSS Stylesheet doesn't work in a .cfm file
Copy link to clipboard
Copied
Hi
I have installed CF2016 enterprise as a trial and I have already developed some good paged, getting JSON content from the Internet, parse it and put teh results in a database.
Now that work is completed I want to apply some nice styles to my pages with the following approach:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<CFOUTPUT><title>#Application.Title#</title></CFOUTPUT>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<link rel="stylesheet" type="text/css" href="vendor/perfect-scrollbar/perfect-scrollbar.css">
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
...normal HTML and CF content
So here is my problem:
The cfm page works fine, all queries get executed and the HTML tables filled but my styles are like ignored. If I run the same file directly from disc like this:file:///C:/coldfusion/cfusion/wwwroot/ptr/index2.cfm all styles are applied
however if I un the same file over CF2016 like this http://127.0.0.1:8500/ptr/index2.cfm all styles are ignored. I checked the page source and see the stylesheet command but it looks like CF does something before it send the file to he browser. I've tried lates Firefox, Chrom and MS Edge
Any idea?
Thanks in advance
Regards
Daniel
Copy link to clipboard
Copied
I suspect you have some path issue that is being exposed when you run the file through CF, that isn't when you run the file through the local filesystem. I suspect that if you renamed the file index2.html you'd see the same issue running it through CF. In other words, I doubt CF is actually the cause here, because it is very unlikely that it would rewrite your file in the way you describe.
I would recommend you look at using site-root-relative paths for your CSS and other assets.
Dave Watts, CTO, Fig Leaf Software
Copy link to clipboard
Copied
Place the files in the following folders:
wwwroot/ptr/images/icons/favicon.ico
wwwroot/ptr/vendor/bootstrap/css/bootstrap.min.css
wwwroot/ptr/fonts/font-awesome-4.7.0/css/font-awesome.min.css
wwwroot/ptr/vendor/animate/animate.css
wwwroot/ptr/vendor/select2/select2.min.css
wwwroot/ptr/vendor/perfect-scrollbar/perfect-scrollbar.css
wwwroot/ptr/css/util.css
wwwroot/ptr/css/main.css

