Warning: Undefined array key "StartingPoint" in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 107 Warning: Cannot modify header information - headers already sent by (output started at /customers/f/f/0/safaribears.de/httpd.www/content.php:107) in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 115 Warning: Undefined variable $WEB_ROOT in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 118 Warning: Cannot modify header information - headers already sent by (output started at /customers/f/f/0/safaribears.de/httpd.www/content.php:107) in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 118 Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 169 CSS Tutorial - Tips and Tricks - problem 1

Problem 1:

Once upon a time there was a table, looking like this:

This is my cat
sample pic
Nashville
This here is the description, and the height of the whole row should be determined by the height of this cell, and the image on the left should always center middle/middle. Even when the text makes the right part higher than the left part. There is text above and below the image, too.

How can I do that in tableless design, and still have the image centered?

Problem solved:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.
Top Text
Bottom Text

Explanation

What has helped was the fact that the pictures all have the same height and width.
The image is a background image of the section div
For getting the text wide enough to the right, I am using padding-left, with the value (here 150px, in red) resulting from width-of-image plus 2x empty space around it (requested was 10px). 130 + 2x 10 = 150px.
The width of the two short lines has to be the same as the padding of the whole section div (in this case 150px, in red).
Since the section div would fall short if the text is not so long, I have to set a min-height, which is the height of the image, plus enough space for the two short text lines above and below. See part in purple.
The positioning of the background-image has the horizontal position (green) set to 10px, which is the requested padding for the image.
The overall width of the full element is here set to 70% (brown). But beware, the actual width of the element is 70% plus the width of the padding (here 150px)!
➔ Only the colored parts of the code should be changed (adjusting to different sizes).
The empty box with the class "clickarea" is only serving as clickable area, since background images can't be made linked. In the onclick command (colored in teal) is the URL for the destination to go.

Code:

The Styles:

div.section{
position:relative;
width:70%;
border:solid black 1px;
background-repeat:no-repeat;
background-position:10px 50%;
padding-left:150px; min-height:130px;
cursor:pointer;
background-image:url('nash.jpg');
}
div.section > div[class|="text"]{
position:absolute;
left:0px;
width:150px;
text-align:center;
}
div.section > div.text-top{
top:0px;
}
div.section > div.text-bottom{
bottom:0px;
}
div.section > div.clickarea{
height:inherit;
width:150px;
position:absolute;
top:0;
left:0;
}

The XHTML part:

<div class="section">
Here comes the long text (lorem ipsum...)
<div class="text-top">
here comes the short text on top of the image
</div>
<div class="text-bottom">
here comes the short text below the image
</div>
<div class="clickarea" onclick="location = 'content.php?page=csstutorial&chap=12'"> </div>
</div>