Ricky Mason
Ricky Mason

Reputation: 1828

linking to css in localhost getting lost in multiple pages

I just recently installed XAMPP and have been trying to get my former website which was hosted online to work in it.

Everythings okay until I navigate past my baseurl. To make matters a bit more complicated, i've been the page using jquery-mobile so all the content is fetched through AJAX.

baseurl = 127.0.0.1/mobilebrowsergame/

When I refresh(start) on this page, everythings okay because it uses the default root for the CSS files.

However, if I start/refresh on a page a bit deeper, ie.

127.0.0.1/mobilebrowsergame/structure/1

The css obviously doesnt work.

I originally included <?php echo base_url() ?>css/stylesheet.css ?> but was forced to remove the base_url() because it wasn't loading under localhost.

At this point, I'm at a loss. I don't know how to tackle this without creating a new CSS for ever page under the base.

Any ideas?

Upvotes: 0

Views: 530

Answers (1)

Julian H. Lam
Julian H. Lam

Reputation: 26134

It looks like you are pointing to your CSS files using a relative URL. If you prepend a path with /, it will automatically start at the web serve root (in this case, 127.0.0.1), instead of at the current directory.

i.e. Try this

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

Upvotes: 3

Related Questions