[SOLVED] using background images to fill div's

This is a discussion on "[SOLVED] using background images to fill div's" within the Web Page Design section. This forum, and the thread "[SOLVED] using background images to fill div's are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 29th, 2007, 19:38
Reputable Member
Join Date: May 2007
Location: Margate
Age: 24
Posts: 156
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] using background images to fill div's

I am trying to use CSS to fill in a div, using the backgoround image property.

Code: Select all
#banner {
 background-image: url(assets/images/banner.gif);
}
Code: Select all
#banner {
 background-image: url(assets/images/banner.gif);
 height: 100px;
 }
have tried the above even making the div the height of the image.


where am i going wrong.

any help will be grateful

Cheers
Dan

  #2 (permalink)  
Old Sep 29th, 2007, 19:49
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: using background images to fill div's

You will need a width (width of the image)
  #3 (permalink)  
Old Sep 29th, 2007, 19:50
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: using background images to fill div's

I'm presuming your problem is that the image is not appearing?

I think you have missed the background-position and background-repeat properties!

Code: Select all
#banner {
background-image: url(....banner.gif);
background-repeat: no-repeat;
background-position: top;
width: the width of your image or more;
}
You do need to also add a width to your div, it needs to be the same width as the div or greater, and the same with the height.

Good luck!

HtH!

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
  #4 (permalink)  
Old Sep 29th, 2007, 20:07
Reputable Member
Join Date: May 2007
Location: Margate
Age: 24
Posts: 156
Thanks: 0
Thanked 0 Times in 0 Posts
Re: using background images to fill div's

You beauti, It has work thanks for that, as per usually amazingly fast response.

Cheers

Dan
  #5 (permalink)  
Old Sep 29th, 2007, 20:14
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: using background images to fill div's

I dont think you need :
Code: Select all
background-repeat: no-repeat;
background-position: top;
IF you use the div the same width and height of the image. I think....
  #6 (permalink)  
Old Sep 29th, 2007, 20:45
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: using background images to fill div's

Actually I think you are right! So all you need is:
Code: Select all
background-image:
width: (must be equal to image or greater)
height: (must be equal to image or greater).
Actually, I'm not so sure. If I hadn't of been on dreamweaver for 6 hours today I might have been bothered to open it and check but I can't!
Saves some file space I spose

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
  #7 (permalink)  
Old Sep 29th, 2007, 20:46
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: using background images to fill div's

I think it has to be EQUAL to image or it might repeat. Only way to find out is to try it
  #8 (permalink)  
Old Sep 29th, 2007, 20:58
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: using background images to fill div's

If you set the width to greater than you will need the background-repeat then.

EDit - Ok, I tried.

If you set the width and height to be greater than your image, then you will need to use:
Code: Select all
background-repeat: no-repeat;
It will then default place your image in the top left of the containing div. To change this you need to add:
Code: Select all
background-position:
Remebering that the choices for background position are:
top right left center bottom inherit
And that you can match 2 like so:
Code: Select all
background-position: top left;
There

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
  #9 (permalink)  
Old Sep 29th, 2007, 21:03
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: using background images to fill div's

Quote:
Originally Posted by jackfranklin View Post
If you set the width to greater than you will need the background-repeat then.

EDit - Ok, I tried.

If you set the width and height to be greater than your image, then you will need to use:
Code: Select all
background-repeat: no-repeat;
It will then default place your image in the top left of the containing div. To change this you need to add:
Code: Select all
background-position:
Remebering that the choices for background position are:
top right left center bottom inherit
And that you can match 2 like so:
Code: Select all
background-position: top left;
There

Jack
Thanks for that Jack! That clears everything up.
  #10 (permalink)  
Old Sep 29th, 2007, 21:05
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: using background images to fill div's

No worries happy to help

I'll have a whole site up soon with some of my small tutorials with stuff like this.

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] having a couple of div's underneath each other? cosmicbdog Web Page Design 21 Dec 3rd, 2007 11:46
[SOLVED] Trouble hiding/showing DIV's recreant JavaScript Forum 5 Dec 3rd, 2007 05:57
[SOLVED] using background images in a list marisa Web Page Design 3 Nov 28th, 2007 12:55
[SOLVED] pentool with a fill? ahwell Flash & Multimedia Forum 7 Oct 31st, 2007 11:19
[SOLVED] Background Images admiral1977 Starting Out 6 Oct 29th, 2007 15:31


All times are GMT. The time now is 07:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43