dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Stretching background image to fit screen

  1. #1
    Join Date
    Apr 2005
    Posts
    1

    Stretching background image to fit screen

    Can anyone help me - a kind of HTML novice?
    I would like to use an image as a background - but the image is a fixed size. Is there a way to have the image fit the screen regardless of the screen resolution being used - as can be done in Desktop Properties/background.
    I'm using XP.
    Thanks in advance - John

  2. #2
    Join Date
    Apr 2003
    Location
    UK
    Posts
    2,203
    Please try the following


    <HTML>
    <HEAD>
    <TITLE>Document Title</TITLE>

    <style>
    body{margin:0px}
    .bg{
    position: absolute;
    top:0px;
    left:0px;
    width:100%;
    height:100%;
    z-index:0;
    }
    </style>

    </HEAD>
    <BODY>

    <img class="bg" src="pic.jpg" border="0">
    <div style="position:absolute;z-index:5">Body Contents</div>

    </BODY>
    </HTML>
    Last edited by Mr J; 04-15-2005 at 09:08 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles