|
Image Backgrounds
| [Previous] [Main] [Next] |
|
| |
| You can cause an image to be displayed as the background of a page, such that it appears behind any text or graphics. Image backgrounds are specified as part of a document body, which html++ represents as the htmlBody class. The htmlPage class contains an embedded htmlBody object, which can be accessed using the htmlPage::Body() method.
| |
|
| |
| Image backgrounds can be specified in two ways:
| |
|
|
| |
| Of the two techniques, the first approach is more common as the htmlPage class is a common component of most html++ applications.
| |
|
| |
| Browsers will tile image backgrounds as necessary to fill the entire page background. For this reason, specifying small square images is an easy way to create an attractive pattern. If you want to display a large image only once, such as a company logo, the background image will have to be rather large to prevent the user from seeing the tile effect.
| |
|
| |
| The following example shows how to specify a background image for a document.
| |
|
| |
|
| |
| #include <stdio.h>
| |
| #include <stdlib.h>
| |
| #include <dcmicro/htmlpp/htmlpp.h>
| |
|
| |
| int main( void )
| |
| {
| |
| htmlCgi server ;
| |
| htmlPage page( "html++ example application" ) ;
| |
|
| |
| page.BackgroundImage( "http://www.dcmicro.com/images/main_logo.gif" ) ;
| |
|
| |
| page << "This is an example of a page with "
| |
| "a background image." ;
| |
|
| |
| server << page ;
| |
| return 0 ;
| |
| }
| |
|
| |
|
| |
| Content-Type: text/html
| |
| <HTML>
| |
| <HEAD>
| |
| <TITLE>html++ example application</TITLE>
| |
| </HEAD>
| |
| <BODY BACKGROUND="http://www.dcmicro.com/images/main_logo.gif">
| |
| This is an example of a page with a background image.
| |
| </BODY>
| |
| </HTML>
| |
|
| |
|
| |
