Solved

How do I add a background to a cascading style sheet?

Posted on 2007-11-14
10
323 Views
Last Modified: 2010-04-21
I have some code of a cascading style sheet that I would like to put a back ground in the website that it references but I don't have the website it references.  I have the background image on disk, how do I code in the background image in the CSS code? John
0
Comment
Question by:Round_Butte
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 20287506
Hi Round_Butte,

.someclass {
                    background: url(images/file.gif)
}
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20287572
To add to jason1178's solution, you can add no-repeat at the back or repeat-x repeat-y for repeating or no repeating of background image, eg:

.someclass
{
      background: url(images/file.gif) no-repeat;
}

Hop ethis helps.
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 20287801
If you background is for the body element (i.e. the page background on every page), then you can assign this directly to the BODY:


body {
     background:white url(somedirectory/myimage.jpg) no-repeat top left;
}

Open in new window

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 20287812
Hey, look who found the new code snippet feature. :)
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 20287850
Yes...
<opinion>
But not very useful for when I'm including multiple chunks of code!
</opinion>

Open in new window

0
 

Author Comment

by:Round_Butte
ID: 20293129
So I use url() regardless if its on the web or hard disk? John
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 50 total points
ID: 20293197
its the relative path to your html file, so if it is in the same directory then just put url(myimage.jpg). Essentially everything is on the hard disk it is just how you reference to the file.
0
 

Author Comment

by:Round_Butte
ID: 20295848
thank you
0
 

Author Closing Comment

by:Round_Butte
ID: 31409290
So I have to build a folder for my files????
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20296504
glad to help!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The goal of the tutorial is to teach the user how to use import presets downloaded from the internet into Adobe Lightroom. Once you downloaded the presets go into the preset folder and press import then import your preset and your set it to go.
The goal of the tutorial is to teach the user the full work flow of how to use flash media encoder to stream onto YouTube.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question