7 Replies - 1663 Views - Last Post: 18 December 2012 - 10:04 PM

#1 ronanbrowne88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 21-November 12

Cant get background image to show in header div?

Posted 16 December 2012 - 07:38 AM

im trying to get a background image to show in my header div but its just not happening for me and im not sure why.

im sure the path ive specified is correct, ive put the image in the main directory so that cant be the problem. any one have any idea whats wrong? hear is the css.

#header{
	background-image:url('banner.jpg');
	width:760px;
	height:100%;
	margin: auto;
	padding:0;


}


This post has been edited by Atli: 16 December 2012 - 08:25 AM
Reason for edit:: Fixed the [code] tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Cant get background image to show in header div?

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Cant get background image to show in header div?

Posted 16 December 2012 - 08:27 AM

Hey. Where is this CSS located? In the HTML document or in an external CSS file? If it's external, where exactly?

I ask because paths inside CSS files are relative to it's position. So if you have this structure:
/
  index.html
  banner.jpg
  css/
    main.css


Then in order for the main.css file to include the banner image, it'll have to do:
background-image: url(../banner.jpg);


Was This Post Helpful? 0
  • +
  • -

#3 ronanbrowne88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 21-November 12

Re: Cant get background image to show in header div?

Posted 16 December 2012 - 09:00 AM

Oh yes your right , i was thinking of it as if it was relative to the index.html. got it working thanks!
Was This Post Helpful? 0
  • +
  • -

#4 khedron  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 52
  • Joined: 20-October 12

Re: Cant get background image to show in header div?

Posted 16 December 2012 - 01:27 PM

also isn't that location supposed to be more like

background-image:url('.../banner.jpg');


Was This Post Helpful? 0
  • +
  • -

#5 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Cant get background image to show in header div?

Posted 16 December 2012 - 01:33 PM

Nope. The quotes are optional, and you use two periods to go up a level, not three.
Was This Post Helpful? 0
  • +
  • -

#6 khedron  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 52
  • Joined: 20-October 12

Re: Cant get background image to show in header div?

Posted 16 December 2012 - 03:22 PM

ahh , a lot of my code is bad then :D , but if i don't do that it ussually navigates from the root folder . instead of the one the html/php file is in
Was This Post Helpful? 0
  • +
  • -

#7 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Cant get background image to show in header div?

Posted 16 December 2012 - 04:30 PM

that's odd. Three periods have no meaning, like one or two periods do. If you use three periods in a path, the browsers will just assume you are looking for a file or directory named using three periods.
Was This Post Helpful? 0
  • +
  • -

#8 khedron  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 52
  • Joined: 20-October 12

Re: Cant get background image to show in header div?

Posted 18 December 2012 - 10:03 PM

i looked at my css again , and you are right , it is two. no idea why i remembered 3 :(/> , but it still doesn't work with out them . (the two periods) would that mean he needs to add them to his code as well?

This post has been edited by khedron: 18 December 2012 - 10:11 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1