Style Sheets
  Home arrow Style Sheets arrow Page 4 - CSS: Backgrounds
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

CSS: Backgrounds
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-03-03

    Table of Contents:
  • CSS: Backgrounds
  • How to Set the Background Color
  • Working with Background Images
  • Positioning the Background Image
  • Text in CSS

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    CSS: Backgrounds - Positioning the Background Image


    (Page 4 of 5 )

    You can position the background image using the background-position property, like this:


    <html>

    <head>

    <style type="text/css">

    body

    {

    background-image:

    url('2.png'); background-repeat:no-repeat;background-position:center;

    }

    </style>

    </head>

    <body>

    </body>

    </html>

    The values at which you can set the position are: top left, top center, top right, center left, center right, center center, bottom left, bottom center, and bottom right.

    You can also position the image using the x% and y%, in this manner:


    <html>

    <head>

    <style type="text/css">

    body

    {

    background-image:

    url('2.png'); background-repeat:no-repeat;background-position:30% 20%

    }

    </style>

    </head>

    <body>

    </body>

    </html>

    This works by setting the first value (%x) as the horizontal position, and the second value (%y) as the vertical position.

    You can also set the image position using pixels by relying on the xpos, ypos value:

    <html>

    <head>


     

    <style type="text/css">

    body

    {

    background-image:

    url('2.png'); background-repeat:no-repeat;background-position:70px 120px;

    }

    </style>

    </head>

    <body>

    </body>

    </html>

    Again, the xpos represents horizontal and ypos represents vertical.

    More Style Sheets Articles
    More By James Payne


       · Thanks for stopping by to read my article on CSS Backgrounds. Here we discuss such...
     

    STYLE SHEETS ARTICLES

    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification
    - CSS: Dimensions
    - CSS: Margins and Padding
    - CSS: Crossing the Border
    - CSS: Text, Fonts, and Tables
    - CSS: Working with Text
    - CSS: Backgrounds
    - CSS for the Newbie







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway