Solved

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

Posted on 2007-11-14
10
318 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
Comment Utility
Hi Round_Butte,

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

Expert Comment

by:nizsmo
Comment Utility
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
Comment Utility
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
 
LVL 70

Expert Comment

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

Expert Comment

by:Rouchie
Comment Utility
Yes...
<opinion>

But not very useful for when I'm including multiple chunks of code!

</opinion>

Open in new window

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:Round_Butte
Comment Utility
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
Comment Utility
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
Comment Utility
thank you
0
 

Author Closing Comment

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

Expert Comment

by:nizsmo
Comment Utility
glad to help!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article shows how to convert a multi-page PDF file into multiple image files, with one image file created for each page of the PDF. It does this by utilizing an excellent, free software package called GraphicsMagick. The solution is amazingly s…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now