Forum Moderators: not2easy
So my question is what's the html/css to do that? I thought this would be really easy but I'm just too new at this to figure it out.
1. That makes the image really thin (the size of the h1 text)
2. I have to put in some kind of text for the image to show up. I just want the image, no text. Here is what I have...
<html>
<head>
<style type="text/css">
h1.title {background:url("/store/includes/languages/english/html_includes/background.gif") repeat-x bottom;}
</style>
</head><body>
<h1 class="title">text</h1>
</body>
</html>
h1.title {
text-indent: -5000px;
height: 78px; /*or whatever you need*/
background: ... } add to that borders, padding and margins to position it.
Reading back to your original question, as an alternative to the <h1>, you can use any tag, including a regular paragraph and put the image you want centered over the background inside that paragraph.
In that case put auto margins (might not work in IE) on the image to center it.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Title</title>
<style type="text/css">
* {padding:0; margin:0} /* reset, can be done less agressive */
#banner {
background:url("background.gif") repeat-x bottom;
height:100px;}
#banner img {
margin: 0 auto 0 auto; /* horizontal centering */
padding-top: 11px; /*half of the extra height to do easy vertical centering*/
height:78px;
width:200px;
display:block}
</style>
</head>
<body>
<p id="banner"><img src="logo.png" alt="graphical logo" /></p>
<h1>title</h1>
<p>ipso lorum</p>
</body>
</html>
I didn't try it in IE (that's not my idea of fun anyway), I kinda expect it to break on centering (use "text-align: center" on #banner if it does) I also avoided trying to vertically center it automatically in the background as I expect IE to have even more trouble there.
I also added a doctype in order to get away from quircks mode (the xml declaration might drop IE back into it though)