?
Solved

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

Posted on 2007-11-14
10
Medium Priority
?
334 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
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

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
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The goal of the tutorial is to teach the user how to make his/her own presets while editing so it is easier to edit there photos. Create a preset you like and copy that setting then save it in to your presets folder.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

752 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