#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2016
    Location
    Lakewood, WA
    Posts
    218
    Rep Power
    17

    css Background issue


    I have all my CSS in a file, located and referenced like so:
    Code:
    <link rel="stylesheet" type="text/css" href="./css/main.css" media="screen" />
    For everything, it's fine. Except the body background:
    Code:
    body { 
    	font-family: Helvetica, Arial, sans-serif;
    	background-image: url("./images/dark.png"); 
    }
    ...also tried...
    Code:
    body { 
    	font-family: Helvetica, Arial, sans-serif;
    	background: url("./images/dark.png") repeat; 
    }
    File paths like so:

    / - main pages
    /css/main.css
    /images/ - image files

    I'm missing something obvious.
    Last edited by Arty Zifferelli; June 18th, 2017 at 10:41 PM.
  2. #2
  3. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    6,110
    Rep Power
    4103
    Relative paths in CSS files are resolved based on the location of the CSS file, so you want your image url to be ../images/dark.png
    Recycle your old CD's



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2016
    Location
    Lakewood, WA
    Posts
    218
    Rep Power
    17
    Originally Posted by kicken
    Relative paths in CSS files are resolved based on the location of the CSS file, so you want your image url to be ../images/dark.png
    Huh. Is this how it's normally done? Seems wonky.

    Also still no background...

    [edit]

    Code:
    body { 
    	font-family: Helvetica, Arial, sans-serif;
    	background: url("../images/light.png") repeat; 
    }
    ...works.

    Maybe I should include it as a file...
    Last edited by Arty Zifferelli; June 19th, 2017 at 12:57 AM.

IMN logo majestic logo threadwatch logo seochat tools logo