1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Background images on body tag CSS issue

Discussion in 'Software' started by BentAnat, 21 Nov 2011.

  1. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    So I normally consider myself quite apt at CSS/HTML, but this one has me stumped.

    A Mate and myself made www.dangerousdavemedia.com as a challenge to ourselves in <8 hours.
    I know it's not 100% semantic and whatnot, but that's not the isssue here.

    It looks right in Firefox, looks ok in Chrome and Safari.
    When opening the page in IE7/8 (9 not tested), and in Opera (latest one on the mac), the <body>-attached background picture doesn't show.

    Opera Drangonfly shows that the path is right and that it DOES download the image, but doesn't show it.
    I have tried adding a new div and attaching the image there, to no avail.
    I have tried adding it to the <html> element, and that also doesn't work.
    I have tried specifying the width and height of the <body> element, which also doesn't work

    :wallbash:

    I have tried googling this issue, and found about two million options, but none that seem feasible.
    Any thoguhts would be appreciated.
     
  2. Votick

    Votick My CPU's hot but my core runs cold.

    Joined:
    21 May 2009
    Posts:
    2,321
    Likes Received:
    109
    Code:
    background-image: url(http://www.dangerousdavemedia.com/images/bg_explosion.png);
    When using URLS do

    Code:
    background-image: url('http://www.dangerousdavemedia.com/images/bg_explosion.png');
    This might be your problem, you did it on the other images except this one.

    I never user the whole URL why can't you just use

    Code:
    background-image: url(images/bg_explosion.png);
     
  3. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    I changed that in an attempt to fix it...
    anything int he url() bit doesn't technically need quotes.

    and yes, I could use relative paths, but I have in the past picked up issues between relative paths and .htaccess rewrite rules (which I use for the URLs).

    So no... that's not the issue.
     
  4. Zoon

    Zoon Hunting Wabbits since the 80s

    Joined:
    12 Mar 2001
    Posts:
    5,888
    Likes Received:
    824
    I just opened it in both IE9 and Firefox 8 and it looked identical. I'm guessing you have fixed it in the intermediate term?

    If not and its just me ....

    I put the following internet explorer tag in all my pages now as it forces both IE8 and IE9 to behave much 'better' - this may help you out.

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    Also, I know the url doesn't technically need the single quotes, but I always use them and I've only ever seen them used so maybe it will help?
     
  5. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    Like I said - I added and removed them to try to debug issues - makes no difference in either browser.
    if IE 9 and FF look the same, that's good neews... that' means that IE9 renders it correctly.

    Will try the IE fix you posted.
    The issue seems to be Opera and IE7/8
     
  6. Modsbywoz

    Modsbywoz Multimodder

    Joined:
    14 Oct 2009
    Posts:
    2,778
    Likes Received:
    273
  7. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    so shorthand rather than the long form?
    As for the shorthands - it's a dirty workaround for Mod-Rewrites in Apache...
     
  8. Zoon

    Zoon Hunting Wabbits since the 80s

    Joined:
    12 Mar 2001
    Posts:
    5,888
    Likes Received:
    824
    I usually absolute link from top level so /images/whatever.jpg and then add images to exclusions list.
     
  9. Modsbywoz

    Modsbywoz Multimodder

    Joined:
    14 Oct 2009
    Posts:
    2,778
    Likes Received:
    273
    you could do something like this....

    background: url(../Images/Image.jpg) no-repeat top left;

    Would make it easier when working on a local PC too. Saves uploading all of your images to the live site while in development.
     
  10. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    Images as an exception is a good idea...
    but yah... that's something one can work around... the issue I have is the image loading (according to Dragonfly) but not showing... so it's not a path issue...
     
  11. Zoon

    Zoon Hunting Wabbits since the 80s

    Joined:
    12 Mar 2001
    Posts:
    5,888
    Likes Received:
    824
    No because then its a relative path and not an absolute path...

    When you hit mydomain.com/ it'll try ../images which is above webroot, and won't exist.

    When you hit mydomain.com/folder1/folder2/ it'll try ../images which is mydomain.com/folder/images which also won't exist :)

    If you do /images/myfile.ext in all your code, wherever you reference the CSS will always check the images folder within the webroot folder.

    My .htaccess for reference:

    Code:
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    My folder structure looks like a simple variation of:

    /http_root/
    /http_root/.htaccess
    /http_root/index.php
    /http_root/robots.txt
    /http_root/css/
    /http_root/images/
    /http_root/js/
     
    BentAnat likes this.
  12. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    Yup... Zoon - that's what I was thinking as well.
    Have rep for that.

    As for the bug - I fixed it, and it had nothing to do with paths, shorthand or quotes...
    The background image is quite tall.
    As such, Opera and IE7/8 wouldn't show it. Body can not be set to a min-height in all browsers, and it would be really whack to set a min-height of, say 1800px on a page that has 3 lines of content and needs less.

    So I trimmed the height of the image down, and VOILA!
    so we learn. :thumb:
     
  13. Zoon

    Zoon Hunting Wabbits since the 80s

    Joined:
    12 Mar 2001
    Posts:
    5,888
    Likes Received:
    824
    Thanks for the rep - I tend to use codeigniter for my websites (even the easy ones) as its so quick, and this is the folder structure I've begun to work with as a result. Not shown obviously are the hidden folders above webroot where all the good stuff is kept :)

    Yeah min-height is a funny one, its not very compatible as you say. I try to avoid it.

    You'd be much better (where possible) to use a tesselating square background, which in honesty is what I'd assumed you had done :thumbs:
     
  14. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    The stripey pattern behind is just taht... a pattern... the 'splosion would've been a bit difficult like that.
    My folder structure looks a lot like that, zoon... and that's without me using codeigniter... just good practise, i suppose.
     
  15. Daedelus

    Daedelus What's a Dremel?

    Joined:
    7 May 2009
    Posts:
    253
    Likes Received:
    12
    wait, people still use IE?
     
  16. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    About 70% of people, according to 4 weeks of moderate-traffic data I have (that's about 500 page views a day... 100-odd visits daily)
     

Share This Page