Computer Graphics Community
Adding image in a style - Printable Version

+- Computer Graphics Community (http://www.cgshelf.com/forum)
+-- Forum: Web Designing (/forum-39.html)
+--- Forum: CSS (/forum-44.html)
+--- Thread: Adding image in a style (/thread-12.html)



Adding image in a style - jsguy - 02-14-2007 05:35 PM

Hi

How can I add an image to a CSS style. Say I need 'img.gif' as a background image for a particular style.

Thanks


RE: Adding image in a style - albinjoseph - 02-14-2007 05:45 PM

You can use the background-image property to set the backgound image inside a style

For eg: the following style would add a img.gif as the image background.

Code:
<style type="text/css">
.imgStyle {
    background-image: url('img.gif');
}
</style>

Code:
<div class="imgStyle">This is a background with image </div&gt;



RE: Adding image in a style - jsguy - 02-14-2007 05:56 PM

Thanks. It worked.


RE: Adding image in a style - marclewis - 07-16-2014 10:41 AM

Example:

style="background:url(image.jpg) no-repeat center center; width:150px, height: 150px;"