Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 02-26-2008, 11:09 AM CSS Going Haywire!!
Novice Talker

Posts: 14
Location: UK
Trades: 0
Hey all, I've just run into one more problem with my site... Each area is kept in it's own folder (mainly to keep things a bit tidy, but also to allow a simple PHP breadcrumb script to work...) . I have a PHP CSS Switcher running which allows the user to choose between two different styles (both exactly the same bar background really...) and am referencing my stylesheets with '../css/XXX.css' so that it will work from any folder.

The design works fine on my index page here, but when I call the same style sheets from another page for example from my videos page here it goes completely crazy and knocks all of my positioning elements out...

Does anyone know why this could be?

(here is a link to my CSS file if it helps!)
hj8ag is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-26-2008, 11:58 AM Re: CSS Going Haywire!!
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Your problem seems to be that you're using relative URLs as opposed to absolute URLs. For some reason, the prevailing wisdom among designers is to use relative URLs because it's "easier" from a design point of view and saves bandwidth, and among SEOs it's to use absolute URLs for issues of canonicalization (an absolute path defines one URL absolutely).

This is one of the rare times when the SEO community gets a design issue right, albeit for another reason in your case. The reason you want to use absolute URLs is because you use subfolders in your layout. By using absolute URLs, you can tell the server exactly where the CSS is, where the Javascripts are, etc. and so on. The increased bandwidth is marginal at best, and you're sure that your layout works every time.

My own trick is to have a variable called Page_Root (and another called Image_Root) in an include file, and define the paths for both localhost (my server) and the live server.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-27-2008, 04:06 AM Re: CSS Going Haywire!!
RadGH's Avatar
Skilled Talker

Posts: 76
Name: Radley
Trades: 0
Sounds like the same problem that I had recently. Except with CSS you would use the URL path rather than the directory path.

This was explained later in the post.

Heres what your looking for (php)

PHP Code:
<LINK REL=StyleSheet HREF="http://<?php echo $_SERVER['HTTP_HOST'];?>/css/style.css" TYPE="text/css">
It works on my website. Just note that if an image isn't showing up you may need to apply the same PHP code to all images and background images inside the css document.


[unrelated] These reply boxes really need a word wrap feature, the entire paragraph spans the same line and extends the entire textarea...
RadGH is offline
Reply With Quote
View Public Profile
 
Old 02-27-2008, 04:29 AM Re: CSS Going Haywire!!
Novice Talker

Posts: 14
Location: UK
Trades: 0
Hey guys, thanks for the responses...


Unfortunately doesn't look like it's because of Relative URLS's... I'm now using absolute inks (targeting the CSS through basically a web address to my css file) and it is still not behaving...

Do you think it could be something to do with the PHP I am using?
hj8ag is offline
Reply With Quote
View Public Profile
 
Old 02-27-2008, 05:27 AM Re: CSS Going Haywire!!
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
remove the ../ and use root relative addressing.

because "/css/style.css" is the same no matter where the document is in the structure.

"../css/style.css" always means one directory above the current location.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to CSS Going Haywire!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.55632 seconds with 12 queries