Welcome Guest, Not a member yet? Register   Sign In
relative paths inside css file
#2

(This post was last modified: 12-17-2015, 07:46 PM by meow.)

(12-17-2015, 11:02 AM)Aleksi Wrote: Hi there. Longtime professional CG coder, but (relatively) new to web tech and php. (I did support a django website for a while, though.) That said, I've looked around at quite a few frameworks and CodeIgniter strikes me -- by far! -- as the most elegant and intuitive that I've come across, so much so that it's worth it to me to finally learn PHP.

I'm finally refactoring my website (currently all static pages) by diving into codeigniter. It's going well, got my controllers and views working. (Not using models just yet...)

But I'm having a problem loading a font-family through a css file. I've scoured the web but couldn't find a solution that worked for me, hence I'm coming here.

My css and js files are loading just fine. One css file contains the following:

Code:
  @font-face {
    font-family: 'WebSymbolsRegular';
    src: url('websymbols/websymbols-regular-webfont.eot');
    src: url('websymbols/websymbols-regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('websymbols/websymbols-regular-webfont.woff') format('woff'),
         url('websymbols/websymbols-regular-webfont.ttf') format('truetype'),
         url('websymbols/websymbols-regular-webfont.svg#WebSymbolsRegular') format('svg');
    font-weight: normal;
    font-style: normal;
  }

The directory structure is pretty straightforward:

|-root
  |-theme
    |-stylesheets
      |-websymbols

Some people have asked the same question at StackOverflow, but the suggestions didn't work for me (such as editing the .htaccess file to add exclusions for the pertinent directories).

The font-face has always loaded for me in the past, but codeigniter doesn't seem to like relative links inside the css file. I've tried every variation of relative path structures I could think of, but nothing worked. It also doesn't seem to like absolute paths when I spell out the absolute url of the websymbols directory (using the value returned by base_url())!

Any helpful suggestions very appreciated!

PS Yes, codeigniter uses "assets" as a dirname convention, but to make my life easier I'm sticking with my original "theme" dirname.


Are you following along the tutorial in the docs? Mind pasting here the call method to your CSS/JS files?
Here is how I've got it to work for my first app I'm working on:

Structure:


Code:
|--root
   |--application
      |--views
         |--templates
            |--header.php
   |--css
      |--20151206.css
   |--img
   |--system


Inside my header I have:
Code:
<!DOCTYPE html>
<html>
    <head>
        <title><?php echo htmlspecialchars($title); ?></title>

        <?php echo link_tag(base_url().'css/20151206.css'); ?>

        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>

    <body>


Inside the CSS I have:
Code:
@media screen and (min-width:500px){
    html {
        background: url(../img/dufer.jpg) fixed;
        background-size: cover;
        overflow: auto;
        }
}


And it works fine. EDIT: Just noticed your CSS has 'src' and I havent tried that yet.
Reply


Messages In This Thread
relative paths inside css file - by Aleksi - 12-17-2015, 11:02 AM
RE: relative paths inside css file - by meow - 12-17-2015, 07:44 PM
RE: relative paths inside css file - by Aleksi - 12-17-2015, 08:53 PM
RE: relative paths inside css file - by InsiteFX - 12-18-2015, 05:15 AM
RE: relative paths inside css file - by Aleksi - 12-18-2015, 05:21 AM
works now...? - by Aleksi - 12-18-2015, 02:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB