Solved

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

Posted on 2007-11-14
10
331 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
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
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.
The goal of the tutorial is to teach the user how to remove a natural vignette your photos and how to add vignette to your photos.

707 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