Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-11-14
10
Medium Priority
?
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 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

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The goal of the tutorial is to teach the user what gradient filters are and how to use them. When you have a photo and some part of the photo is either over exposed or under exposed, you use a gradient filter to help mask the need to touch up th…
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.
Suggested Courses

604 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