Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1721 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     HTML/XHTML/DHTML/CSS :

CSS: background image in a content box.

Thread title: CSS: background image in a content box.
Closed Thread    
    Thread tools Search this thread Display Modes  
09-14-2005, 03:48 AM
#1
Yang is offline Yang
Yang's Avatar
Status: Member
Join date: Jun 2005
Location:
Expertise:
Software:
 
Posts: 460
iTrader: 0 / 0%
 

Yang is on a distinguished road

Send a message via Yahoo to Yang

  Old  CSS: background image in a content box.

This one should be a challenge, i should think.

Here's the situation:

I have a typical content box sliced into three images, namely: the header.gif (200 x 20 pixels), the content.gif (1 pixel in height, set to repeat vertically downwards) and of course, the footer.gif (200 x 20 pixels).

I coded the contentbox using CSS:

Code:
#container 
{
width: 200px
padding: 0;
margin: 0;
}

#header
{
background: url('header.gif') no repeat;
padding: 0;
margin: 0;
height: 20px;
width: 200px;
}

#content 
{
background-image: url('content.gif') repeat-y;
padding: 0;
margin: 0;
width: 200px;
}

#footer
{
background: url('footer.gif') no repeat;
padding: 0;
margin: 0;
height: 20px;
width: 200px;
}
And the html file:

Code:
<div id="container">
   <div id="header"></div>
   <div id="content"> Content goes here </div>
   <div id="footer"></div>
</div>

So that's pretty basic. As you add more content between the content div tags, then the content.gif will automatically repeat itself vertically downwards, since the content.gif is set as the background image of the content div tags. But what if I wanted to add an image as a background of the content area, let's say an image of a puppy. But the background-image is already the content.gif.

The final work should look like this:

Hmm, what do you say, challenging? A client actually requested that I should have an image as a background of the content boxes, but i'm not sure how i can do that. Any help would be appreciated. Oh, and hi

09-14-2005, 09:19 AM
#2
Julian is offline Julian
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
 
Posts: 5,572
iTrader: 0 / 0%
 

Julian is on a distinguished road

  Old

You could have that image but remember to set it to no-repeat and have a matching background colour that can expand the box underneath the image. You will also have to ensure there is always enough content inside the content box to enable the image viewing in full.

09-14-2005, 12:01 PM
#3
Yang is offline Yang
Yang's Avatar
Status: Member
Join date: Jun 2005
Location:
Expertise:
Software:
 
Posts: 460
iTrader: 0 / 0%
 

Yang is on a distinguished road

Send a message via Yahoo to Yang

  Old

Hey Julian, how are you? Maybe it isn't a challenge after all. So let's say i get the puppy.gif image. I replace the content.gif with it like this..

#content
{
background-image: url('puppy.gif') no-repeat;
background-color: /*matching bg color*/
padding: 0;
margin: 0;
width: 200px;
height: 100px
}

It should work!

Only one problem. This is the current background image of the content area:

and this is the outcome:

09-14-2005, 12:47 PM
#4
chaka42 is offline chaka42
Status: Senior Member
Join date: Apr 2005
Location: Middle America
Expertise:
Software:
 
Posts: 955
iTrader: 5 / 100%
 

chaka42 is an unknown quantity at this point

Send a message via AIM to chaka42 Send a message via MSN to chaka42 Send a message via Skype™ to chaka42

  Old

in this case, the solution is rather simple:

make your dropshadow/gradient image the bg of the container div. since you have the images of the header and footer overlapping the container, the bg image for the container repeats then as the content div increases length. then make the image of the puppy the bg of the content div.

09-15-2005, 08:30 AM
#5
Julian is offline Julian
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
 
Posts: 5,572
iTrader: 0 / 0%
 

Julian is on a distinguished road

  Old

lol, chaka explained it

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed