Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image and text float

Status
Not open for further replies.

harrymossman

Technical User
Sep 5, 2002
255
US
Just started trying to understand css. I need to create a typical letterhead top. I.e., image in the top left corner of the page, organization name and address in the top center.

The following works well at 800 X 600 but I would like for the text position to be relative so that it looks good at any resolution.

Code:
<DIV ALIGN=&quot;left&quot;>
<IMG SRC=&quot;../../images/logo.gif&quot; WIDTH=&quot;91&quot; HEIGHT=&quot;89&quot;>
</DIV>
<div style=&quot;width: 400px; margin-left: 165px&quot;> 
<h1 CLASS=&quot;center&quot;>organization</H1>
<h2 CLASS=&quot;center&quot;>division</H2>
<P CLASS=&quot;center&quot;>office <br>
street address<br> 
city, state 12345</P>
</DIV>

Harry
 
I'll show you one way to do it, and I'll separate out the css from the html:
HTML:
Code:
<div id=&quot;header&quot;>
 <img src=&quot;image.jpg&quot;/>
 <h1>organization</h1>
 <h2>division</h2>
 <p>office<br>
 street address<br>
 city, state 12345</p>
</div>
CSS:
Code:
#header{
 width: 100%;
 text-align: center;
 /*add background color here if you want as well*/
}
#header img{
 position: absolute;
 top: 0px;
 left: 0px;
 width: 91px;
 height: 89px;
}

This will put the image at the top left of the page and the text in the center of the page. If you'll have more than one image in the header, you'll want to give them id's instead of doing '#header img' like I did.

Kevin
A+, Network+, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top