Image position in Opera differs from Firefox and Chrome

Hello Good People,

Please, take a look at this site http://yogastudio.atspace.com/

Issue: the following images get nudged down in Opera but look ok in Firefox and Chrome

<img id="mon" src="images/mon_img.png" alt="" width="113" height="113"/>
<img id="tue" src="images/tue_img.png" alt="" width="113" height="113"/>
<img id="wed" src="images/wed_img.png" alt="" width="113" height="113"/>
<img id="thu" src="images/thu_img.png" alt="" width="113" height="113"/>
<img id="fri" src="images/fri_img.png" alt="" width="113" height="113"/>
<img id="sat" src="images/sat_img.png" alt="" width="113" height="113"/>
<img id="sun" src="images/sun_img.png" alt="" width="113" height="113"/>

Any advice is appreciated

It breaks pretty wildly in Firefox, too, depending on the user’s font size.

relative positioning is not the best choice for positioning most objects. Between relative positioning and ems for positioning, it breaks according to the user’s font size and platform, and browser.

I suggest you reconsider your layout strategy and put each row in its own box, which in turn, are within a “calendar” container… or something like that.

thanks ronpat. should I use any positioning at all for scenario you suggest or just use padding/margin to move boxes around within container? also which length unit you suggest?

If each day-of-the-week were in a separate table, the day-of-the-week image could be absolutely positioned to the top left corner of the table (you cannot p:a within table-cells, of course); thereby, using px to position that image. It should be possible to align the columns vertically by giving each table table-layout:fixed and assigning widths to the columns. It’ll take some experimenting, but I believe that will work reasonably well in your fixed width layout.

Something like this:


table {
    position:relative;
}
.day-image {
    position:absolute:
    top:-20px;
    left:-20px;
}

<table>
    <img class="day-image"></img>
    <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>

The table would be repeated for each day-of-the-week with an image.
(untested)

I guess I am doing something wrong - still breaks in Firefox when I increase font size.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

<title>&#1057;&#1090;&#1091;&#1076;&#1080;&#1103; Sattva</title>

<meta http-equiv="content-type" content="text/html; charset=windows-1251" />

<link href="css/style_1.css" rel="stylesheet" type="text/css" />

</head>


<body>

<h1>&#1056;&#1072;&#1089;&#1087;&#1080;&#1089;&#1072;&#1085;&#1080;&#1077; &#1079;&#1072;&#1085;&#1103;&#1090;&#1080;&#1081;</h1>


<div id="calendar">

<table class="schedule">

<img class="mon-image" src="images/mon_img.png" alt="" width="113" height="113"/>

<thead class="border">
<tr>
<th scope="col" class="col1"></th>
<th scope="col" class="col2">&#1042;&#1088;&#1077;&#1084;&#1103;</th>
<th scope="col" class="col3">&#1047;&#1072;&#1085;&#1103;&#1090;&#1080;&#1077;</th>
<th scope="col" class="col4">&#1055;&#1088;&#1077;&#1087;&#1086;&#1076;&#1072;&#1074;&#1072;&#1090;&#1077;&#1083;&#1100;</th>
</tr>
</thead>


<tbody>

<tr class="height">
<th scope="row"></th>
<td></td>
<td></td>
<td></td>
</tr>



<tr>
<th scope="row">&#1055;&#1085;</th>
<td class="strip">7:30 – 8:30</td>
<td class="strip">&#1062;&#1080;&#1075;&#1091;&#1085;</td>
<td class="strip">&#1057;&#1074;&#1077;&#1090;&#1083;&#1072;&#1085;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>

<tr>
<th scope="row"></th>
<td>9:00 – 10:30</td>
<td>&#1061;&#1072;&#1090;&#1093;&#1072;-&#1081;&#1086;&#1075;&#1072;</td>
<td>&#1054;&#1083;&#1100;&#1075;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>

<tr>
<th scope="row"></th>
<td class="strip">11:00 – 12:00</td>
<td class="strip">&#1049;&#1086;&#1075;&#1072; &#1076;&#1083;&#1103; &#1073;&#1077;&#1088;&#1077;&#1084;&#1077;&#1085;&#1085;&#1099;&#1093;</td>
<td class="strip">&#1054;&#1083;&#1100;&#1075;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>


<tr>
<th scope="row"></th>
<td>12:30 – 16:30</td>
<td>&#1042;&#1088;&#1077;&#1084;&#1103; &#1076;&#1083;&#1103; &#1080;&#1085;&#1076;&#1080;&#1074;&#1080;&#1076;&#1091;&#1072;&#1083;&#1100;&#1085;&#1099;&#1093; &#1079;&#1072;&#1085;&#1103;&#1090;&#1080;&#1081; &#1081;&#1086;&#1075;&#1086;&#1081;</td>
<td>&#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>


<tr>
<th scope="row"></th>
<td class="strip">17:00 – 18:00</td>
<td class="strip">&#1049;&#1086;&#1075;&#1072; &#1076;&#1083;&#1103; &#1073;&#1077;&#1088;&#1077;&#1084;&#1077;&#1085;&#1085;&#1099;&#1093;</td>
<td class="strip">&#1054;&#1083;&#1100;&#1075;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>


<tr>
<th scope="row"></th>
<td>18:00 – 19:00</td>
<td>&#1054;&#1079;&#1076;&#1086;&#1088;&#1086;&#1074;&#1080;&#1090;&#1077;&#1083;&#1100;&#1085;&#1072;&#1103; &#1081;&#1086;&#1075;&#1072; &#1087;&#1086; &#1091;&#1083;&#1091;&#1095;&#1096;&#1077;&#1085;&#1080;&#1102; &#1079;&#1088;&#1077;&#1085;&#1080;&#1103;</td>
<td>&#1054;&#1083;&#1100;&#1075;&#1072; </td>
</tr>

<tr>
<th scope="row"></th>
<td class="strip">19:15 – 20:45</td>
<td class="strip">&#1061;&#1072;&#1090;&#1093;&#1072;-&#1081;&#1086;&#1075;&#1072;</td>
<td class="strip">&#1054;&#1083;&#1100;&#1075;&#1072;</td>
</tr>

<tr class="height">
<th scope="row"></th>
<td></td>
<td></td>
<td></td>
</tr>


</tbody>
</table>

<table class="schedule">

<img class="tue-image" src="images/tue_img.png" alt="" width="113" height="113"/>

<thead >
<tr id="border" >
<th scope="col" class="col1"></th>
<th scope="col" class="col2"></th>
<th scope="col" class="col3"></th>
<th scope="col" class="col4"></th>
</tr>
</thead>

<tbody>

<tr>
<th scope="row">&#1042;&#1090;</th>
<td class="strip">7:30 – 8:30</td>
<td class="strip">&#1062;&#1080;&#1075;&#1091;&#1085;</td>
<td class="strip">&#1057;&#1074;&#1077;&#1090;&#1083;&#1072;&#1085;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>

<tr>
<th scope="row"></th>
<td>9:00 – 10:30</td>
<td>&#1061;&#1072;&#1090;&#1093;&#1072;-&#1081;&#1086;&#1075;&#1072;</td>
<td>&#1054;&#1083;&#1100;&#1075;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>

<tr>
<th scope="row"></th>
<td class="strip">11:00 – 12:00</td>
<td class="strip">&#1049;&#1086;&#1075;&#1072; &#1076;&#1083;&#1103; &#1073;&#1077;&#1088;&#1077;&#1084;&#1077;&#1085;&#1085;&#1099;&#1093;</td>
<td class="strip">&#1054;&#1083;&#1100;&#1075;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>


<tr>
<th scope="row"></th>
<td>12:30 – 16:30</td>
<td>&#1042;&#1088;&#1077;&#1084;&#1103; &#1076;&#1083;&#1103; &#1080;&#1085;&#1076;&#1080;&#1074;&#1080;&#1076;&#1091;&#1072;&#1083;&#1100;&#1085;&#1099;&#1093; &#1079;&#1072;&#1085;&#1103;&#1090;&#1080;&#1081; &#1081;&#1086;&#1075;&#1086;&#1081;</td>
<td>&#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>


<tr>
<th scope="row"></th>
<td class="strip">17:00 – 18:00</td>
<td class="strip">&#1049;&#1086;&#1075;&#1072; &#1076;&#1083;&#1103; &#1073;&#1077;&#1088;&#1077;&#1084;&#1077;&#1085;&#1085;&#1099;&#1093;</td>
<td class="strip">&#1054;&#1083;&#1100;&#1075;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
</tr>


<tr>
<th scope="row"></th>
<td>18:00 – 19:00</td>
<td>&#1054;&#1079;&#1076;&#1086;&#1088;&#1086;&#1074;&#1080;&#1090;&#1077;&#1083;&#1100;&#1085;&#1072;&#1103; &#1081;&#1086;&#1075;&#1072; &#1087;&#1086; &#1091;&#1083;&#1091;&#1095;&#1096;&#1077;&#1085;&#1080;&#1102; &#1079;&#1088;&#1077;&#1085;&#1080;&#1103;</td>
<td>&#1054;&#1083;&#1100;&#1075;&#1072; </td>
</tr>

<tr>
<th scope="row"></th>
<td class="strip">19:15 – 20:45</td>
<td class="strip">&#1061;&#1072;&#1090;&#1093;&#1072;-&#1081;&#1086;&#1075;&#1072;</td>
<td class="strip">&#1054;&#1083;&#1100;&#1075;&#1072;</td>
</tr>

</tbody>


</table>

</div><!--end calendar-->

</body>

</html>
/*start table*/

#calendar {
padding: 1em;
border: 1px dashed green;
}

table.schedule {
     position: relative;
     table-layout: fixed;
     border-collapse:collapse;
     font-family: Arial, Helvetica, sans-serif;
}


table.schedule thead tr {
color: #ef7eb2;
background: #f1fefe;

}

table.schedule thead tr th {
text-align: left;
padding: 7px 0px 7px 0px;

}

.col1 {
width: 70px;

}

.col2 {
width: 120px;

}

.col3 {
width: 450px;

}

.col4 {
width: 350px;

}


.height {
 height: 17px;

}


.mon-image {
    position: absolute;
    top: 102px;
    left: -6px;
    z-index: 2;

}

.tue-image {
    position: absolute;
    top: 287px;
    left: -6px;
    z-index: 2;

}



.strip {
background: #f1fefe;
}

.border {
border-bottom: 2px solid #ef7eb2;
}


#border {
border-top: 2px solid #ef7eb2;
background-color: #fff;
}

Nope, you’re fine. My suggestion was a big fail. Remind me to never post without testing first :confused:

Hopefully, a better (tested) idea will follow…

No worries. We all know we all learn/learned by trial and error. Thanks for your time.

Not to give up! I’ve come up with a solution that works; however, I’m trying to understand {position:relative; top:-8em;} before submitting it.

:slight_smile: no worries. thanks.

You can’t have an image outside the <tr> tag but still inside the table as only table related tags are allowed directly inside the table tag. It needs to be inside a <tr> tag inside the <thead> in order for the HTML to be valid.

Once your HTML is valid it should be easier to ensure that the positioning works consistently.

did you mean something like this,felgall :

<thead class="border">
<tr>
<img class="mon-image" src="images/mon_img.png" alt="" width="113" height="113"/>
<th scope="col" class="col1"></th>
<th scope="col" class="col2">&#1042;&#1088;&#1077;&#1084;&#1103;</th>
<th scope="col" class="col3">&#1047;&#1072;&#1085;&#1103;&#1090;&#1080;&#1077;</th>
<th scope="col" class="col4">&#1055;&#1088;&#1077;&#1087;&#1086;&#1076;&#1072;&#1074;&#1072;&#1090;&#1077;&#1083;&#1100;</th>
</tr>
</thead>

…or like this

<thead class="border">
<tr><img class="mon-image" src="images/mon_img.png" alt="" width="113" height="113"/></tr>
<tr>
<th scope="col" class="col1"></th>
<th scope="col" class="col2">&#1042;&#1088;&#1077;&#1084;&#1103;</th>
<th scope="col" class="col3">&#1047;&#1072;&#1085;&#1103;&#1090;&#1080;&#1077;</th>
<th scope="col" class="col4">&#1055;&#1088;&#1077;&#1087;&#1086;&#1076;&#1072;&#1074;&#1072;&#1090;&#1077;&#1083;&#1100;</th>
</tr>
</thead>

This is a tested example solution to your design request… with caveats.

CSS


.border div {
    position:relative;
}
#mon {
    position:absolute;
    top:-13px;
    left:-41px;
    z-index:2;
}
#tue {
    position:absolute;
    top:-22px;
    left:-36px;
    z-index:2;
}
#wed {
    position:absolute;
    top:-21px;
    left:-33px;
    z-index:2;
}
#thu {
    position:absolute;
    top:-20px;
    left:-33px;
    z-index:2;
}
#fri {
    position:absolute;
    top:-25px;
    left:-36px;
    z-index:2;
}
#sat {
    position:absolute;
    top:-22px;
    left:-36px;
    z-index:2;
}
#sun {
    position:absolute;
    top:-25px;
    left:-36px;
    z-index:2;
}

HTML


<tr class="border">
    <th scope="row"><div><img id="tue" src="images/tue_img.png" alt="" width="113" height="113"/></div></th>
    <td></td>
    <td></td>
    <td></td>
</tr>

*** The top underline does not work properly. That row is coded differently and I have not yet figured it out. ***

The plethora of {position:relative;top:negative-somethings} is poor code. It indicates a fundamental misunderstanding about postioning objects on a page. Likewise, the number of {margin-top:negative-somethings} tells the same tale.

HTML is normally coded to flow smoothly and only requires negative postioning for special purposes.

If you can apply the above example to your page, it will almost be fixed.

The images are not consistently placed within their 113x113 image, thus the slightly different offsets.

This has been tested in FF, Opera, Chrome.

Sorry about the goofy post earlier. My brain sometimes takes unexplainable holidays.

No.
A <tr> is only allowed to contain <th> and/or <td> tags. The <img> should be inside iehter a <th> or a <td> for it to be valid within a table. The example ronpat shows has the <img> tag inside a <th> so the <tab.e> will validate and hence the CSS can work properly.

The plethora of {position:relative;top:negative-somethings} is poor code. It indicates a fundamental misunderstanding about postioning objects on a page. Likewise, the number of {margin-top:negative-somethings} tells the same tale.

I corrected those - it works fine now when I increase fonts. I tested FF Chrome Opera. Yes, I agree that was poor code - I guess sometimes my brain is not there. Sorry. Thanks for pointing this out for me,ronpat.

HTML is normally coded to flow smoothly and only requires negative postioning for special purposes.

Totally agree. Best way is to allow elements take their place naturally and then apply CSS. Thanks again for reminding me.

Here’s the link for the corrected version http://yogastudio.atspace.com/

Please, let me know if I need any more corrections.

I didn’t know about those restrictions. Thanks for your advice,felgall. I’ve also noticed ronpat put an image inside the div

<th scope="row"><div><img id="tue" src="images/tue_img.png" alt="" width="113" height="113"/></div></th>

why use div inside th?

It looks really good to me. Nicely done!

The validator says that the break tags are malformed:

<samp></br></samp> should be written <samp><br/></samp>

Related to the use of break tags… it is recommended that items be given classes, or some such targeting technique, and that margins or padding be used instead of break tags. Doing so gives you better control over the layout and eliminates unnecessary tags. Your call.

The other thing that you can do to tidy up your code a bit is to crop the transparent area out of the day-of-week images. They will end up as 51 x 52 images.

You will then be able to position all of them with just one css entry (instead of 7).


#mon,#tue,#wed,#thu,#fri,#sat,#sun {
    width:51px;
    height:52px;
    position:absolute;
    top:6px;
    left:-5px;
    z-index:2;
}

Of course, I would suggest replacing all of those ids with one classname.

You can download the resized images here if you wish:
https://www.dropbox.com/sh/e1teog7t6o13ktt/EBO8I71rJ8

EDIT:
Tables and table cells cannot be positioned. So, to provide an “anchor” that can be positioned, I put a <div> inside the <th> and set it to {position:relative}. The image can then be set to {position:absolute} with respect to that <div>.

Cheers!

Hi 810311,
In addition maybe some refinements:

  • Table-cells: the empty cells can be removed, with css instead for height positioning. The <td>'s can get more line-height for better readability.
  • Top-borders: can be attached to the tables Tuesday/Sunday themselves.
  • Hidden text for the days: can stay hidden by means of absolute positioning of the day-images: above them. Tables with small height must get extra margin-bottom for compensation.
  • Images: can get some anti-alias.
  • <title>: with the town in it, visitors don’t have to guess in what town the studio is. With the word Йога in it, they don’t have to guess what kind of studio it is. Good for Google. :wink:

All together the html for a table can be:

<table class="schedule borderTop">
	<tbody>
		<tr>
			<th scope="row" class="col1 day" rowspan="9">&#1042;&#1090;<img src="images/tue_img-nw.png" alt="" /></th>
			<td class="strip col2">8:00 – 9:00</td>
			<td class="strip col3">&#1069;&#1085;&#1077;&#1088;&#1075;&#1077;&#1090;&#1080;&#1095;&#1077;&#1089;&#1082;&#1072;&#1103; &#1081;&#1086;&#1075;&#1072;</td>
			<td class="strip col4">&#1054;&#1083;&#1100;&#1075;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
		</tr>
		<tr>
			<td>9:30 – 10:45</td>
			<td>&#1055;&#1086;&#1089;&#1090;&#1085;&#1072;&#1090;&#1072;&#1083;&#1100;&#1085;&#1072;&#1103; (&#1087;&#1086;&#1089;&#1083;&#1077;&#1088;&#1086;&#1076;&#1086;&#1074;&#1072;&#1103;) &#1081;&#1086;&#1075;&#1072;</td>
			<td>&#1054;&#1083;&#1100;&#1075;&#1072; &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;</td>
		</tr>
		<tr>
			<td class="strip">11:00 – 12:00</td>
			<td class="strip">Baby – &#1081;&#1086;&#1075;&#1072;</td>
			<td class="strip">&#1054;&#1083;&#1100;&#1075;&#1072; &#1041;&#1072;&#1088;&#1072;&#1085;&#1086;&#1074;&#1072;, &#1087;&#1086; &#1079;&#1072;&#1087;&#1080;&#1089;&#1080;, &#1085;&#1072;&#1073;&#1086;&#1088; &#1074; &#1075;&#1088;&#1091;&#1087;&#1087;&#1091;</td>
		</tr>
		...
		<tr>
			<td class="strip">19:15 – 20:45</td>
			<td class="strip">&#1050;&#1086;&#1084;&#1087;&#1083;&#1077;&#1082;&#1089;&#1085;&#1072;&#1103; &#1081;&#1086;&#1075;&#1072;</td>
			<td class="strip">&#1044;&#1080;&#1084;&#1072;</td>
		</tr>
	</tbody>
</table>

With the added css:

.schedule {
	margin-bottom: 20px;
	}
.schedule td {
	line-height: 140%;
	}
.borderTop {
	border-top: 2px solid #EF7EB2;
	}
.day {
	position: relative;
	vertical-align: top;
	}
.day img {
	position: absolute;
	left: 0;
	margin-top: -1px;
	}
.extraBottom {
	margin-bottom: 50px;
	}
.bar {
	margin-bottom: 10px;
	}
.imgfloat	{
	margin-top: 15px;
	}

PS: I guess the class “day” can be combined with the class “col1” (if that is not disturbing other pages).

.col2 {
    width: 9em; /* was: 120px; */
}

… and the time column is expanding with growing font-scale. :slight_smile:

Break tags are mostly used for single line breaks. Fixed.

#mon,#tue,#wed,#thu,#fri,#sat,#sun

Selector grouping. Yes, class would work too. Thanks,ronpat.

I also used your images.

Hi Francky, I like your solution too, especially this part

<th scope="row" class="col1 day" rowspan="9">&#1042;&#1090;<img src="images/tue_img-nw.png" alt="" /></th>

It allows to reduce css to the minimum. Good job! Nicely done!