Site relative CSS linking

Associate
Joined
28 Nov 2003
Posts
1,669
Location
EC1V
when I link to a CSS stylesheet a few folders up I use the format (../../css/main.css) for example. As the current build is for prototyping and not always online, I can't link to a css online to keep all links the same.

Is there a way for the import url link to work from the top down like (./css/main.css)? Is there a magic term that makes it work down from the siteroot rather than up from the active html page?

Cheers.
 
This is a large project with the core css file being 74Kb ~3000lines. This is well written code although some could be stripped out as it's been in production for over a year :)

SiriusB: The location of this file is important; (at least) hundreds of pages refer to it. Originally we used a collection of smaller prototypes and worked as you recommended but we really need to pull it all together and make it easier to bolt pages on. There's only so much Find&Replace I can take before I crack. ;)

Cheers for that Augmented, that should help. Does it work on and offline? Will test...
 
I know NOTHING about php, and our resident CSS expert is not a php person either. I'm more of an artist than a coder, so is he except he's great at making solid efficient code. So that [ code ] gibberish made my head explode, so thanks :) I understand the logic, but surely once the 7 CSS files have been cached (total 100Kb) length isn't an issue? Or is what you're suggesting compressing it in memory speeding up every access even once it's cached locally?

And when you say local webserver, I test locally (e.g. right from a desktop file) then uploaded to a remote host for it to be accessed by the rest of the people on the project, (the remote test.)

Thanks.
 
Augmented said:
100,000 uniques/mo @ 74KB = ~7GB transferred
100,000 uniques/mo @ ~20KB = ~2GB transferred

Interesting :0

To be honest I'm not sure what form the CSS will take when it's released. It's 7 files now, two can be disregarded as they are for test templates, two others are IE fixes, one extra IE7 fix file but the core two are the main one and a print one. So they will get combined and reduced in the future.

Thing is it's a large government website (that doesn't exist yet) to have 10s if not 100s of thousands of pages of content. The CSS is built up of the definitions for 40 components and everything has to be specified for every eventuality. When there's 24 lines just for the footer (empty lines taken out) you can the scale of the code. I think. The file is expanded and easy to read at the moment, maybe that's why it's huge... Is there a program that formats css for small file sizes without php? ;)

Code:
#footer {
	background: #fff url(../images/bg.gif) repeat-x left top ;
	padding: 6px 0 30px 0 ;
	height: 1% ;
	margin: 5px 0 10px 0 ;
}
#footer a {
	font: 0.65em/1.1 Tahoma, Arial, Helvetica, sans-serif ;
	color: #2559b0 ;
	text-decoration: none ;
	display: block ;
	padding: 1px 5px ;
	border-right: 1px solid #c8c8c8 ;
}
#footer a:hover {
	background: #F4EA94 ;
}
#footer ul {
	list-style: none ;
}
#footer li {
	float: left ;
}
#footer li.last a {
	border: none ;
}
 
Back to the CSS linking :)

What Augmented suggested works online, on a server; but it won't work offline on an operating system. Or does it? Where does it go back to? to the root of the harddrive? Where's that on a Mac? ;)

Think I might stick to variations of url(../../../../../css) etc Hope this site still works when it gets built dynamically by the database.
 
Back
Top Bottom