Forum Moderators: not2easy

Message Too Old, No Replies

New to css and brain is destroyed :)

need help with placement of an image viewer

         

homesoil

4:43 pm on Sep 21, 2010 (gmt 0)

10+ Year Member



Hi everyone,
I have built a few web sites by hand coding and managed to produce reasonable results.
Trying to learn css now but the margins and paddings and absolute this and that escapes me. I have found an image script that I would really like to use but try as I may I cannot get it positioned on the page correctly inside my table. I have been working with css for 3 weeks in various ways now and I don't want an easy ride but I just don't get it and now I am begging for some help. I have read the posting guidelines but will apologise in advance if I screw up because I think I am asleep.

Here is what I have so far and all I want to achieve is the image viewer far left, the page text centered and the navigation on the right!
I also have the test page uploaded to my server as a standalone page so the images can be viewed which I hope is ok?
www.ljrents dot com/test.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<head>
<title>image test page</title>


<style type="text/css">
.photos {
overflow: hidden;
border: 0px solid #f0f0f0;
padding: 10px;
width: 400px;
margin: 0 auto;
}
img { border: none;}
.photos img.logo {margin: 0 auto; display:block;}
.photos div img {
padding: 10px 0;
margin: 20px 0;
float: left;
border-bottom: 1px solid #ddd;
}
.photos ul.thumbs {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
width: 390px;
float: left;
}
.photos ul.thumbs li{
width: 60px;
height: 100px;
margin: 0 10px 0 0;
padding: 0;
float: left;
overflow: hidden;
position: relative;
border: 5px solid #ddd;
text-align: center;
}
.photos ul.thumbs li:hover {
border: 5px solid #888;
-moz-opacity:.75;
filter:alpha(opacity=75);
opacity:.75;
}
.photos ul.thumbs li img {
position: absolute;
top: -180px;
left: -145px;
}
</style>



</head>

<body>



<table width="750" border="0" bordercolor="purple" cellspacing="0" cellpadding="0" align="center">

<tr>
<td height="5" colspan="3" bgcolor="#9AB1C1"> Test<br>
<img src="images/test.jpg">
<tr><td bgcolor="#9AB1C1"><a href="index.htm"> Home</a></td

</td>
</tr>


<tr>
<td height="300" colspan="2">

<table bgcolor="#C3E1EC" width="100%" border="0" bordercolor="yellow" cellspacing="7" cellpadding="0" height="296">

<tr>
<td valign="top" width="300" rowspan="4"><div class="photos">

<div id="photo_1"><img src="images/jumper1_1.jpg" /></div>
<div id="photo_2" style="display:none;"><img src="images/jumper1_2.jpg" alt="" /></div>
<div id="photo_3" style="display:none;"><img src="images/jumper1_3.jpg" alt="" /></div>
<ul class="thumbs">
<li><a href="javascript:void(0)" onclick="switch_product_img('photo_1', 3);"><img src="images/jumper1_1.jpg" alt="" /></a></li>
<li><a href="javascript:void(0)" onclick="switch_product_img('photo_2', 3);"><img src="images/jumper1_2.jpg" alt="" /></a></li>
<li><a href="javascript:void(0)" onclick="switch_product_img('photo_3', 3);"><img src="images/jumper1_3.jpg" alt="" /></a></li>
</ul>
</div>

<script language="javascript" type="text/javascript">
function switch_product_img(divName, totalImgs) {
for (var i=1; i<=totalImgs; i++) {
var showDivName = 'photo_' + i;
var showObj = document.getElementById(showDivName);
if (showDivName == divName)
showObj.style.display = 'block';
else
showObj.style.display = 'none';
}
}
</script>



<a href="http://www.sohtanaka.com/web-design/css-multiple-image-viewer-thumbnails/">
Multiple Image Viewer</a>
<br>by Soh Tanaka




</td><td width="300">

<p>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.</p>

</td>

<td valign="top" width="150" align="center" height="50">
NAVIGATION</td> </tr>

</table>
<tr>
<td class="footer" bgcolor="#9AB1C1">footer</td>

</tr>
</table>

</body>
</html>

caffinated

7:09 pm on Sep 21, 2010 (gmt 0)

10+ Year Member



Paying attention to your comment that you're not looking for a quick fix, clear the decks and start again but before you do, forget the tables and learn how to use tableless css.

You could do worse than starting by checking out w3schools (google it).

It is worth the learning curve. Tableless CSS is way more manipulative and produces much lighter code (which is good for the SEs).

Probably not what you wanted to hear but it really is sensible advice.

Major_Payne

9:06 pm on Sep 21, 2010 (gmt 0)



As stated, tables are no longer used for page layouts. They went out in the late 1990s with the use of CSS. The web standards are changing again and you need to quit being 10 years plus behind the times like Micro$oft and IE. Tables are still used to present tabular data which was their intended use.

Please, dump the tables. You can do so much more with divs and CSS. Try the following sites:

Tableless Web Design: [en.wikipedia.org...]
Why tables for layout is stupid: [hotdesign.com...]
How to convert manually your HTML tables to CSS: [table2css.com...]
Images, Tables, and Mysterious Gaps: [developer.mozilla.org...]

Post back with a new layout and we'll help you from there. BTW, it's hard helping when code uses relative paths for images (images/jumper1_1.jpg) which we can not pick up in the web editor or checking in the browser.

homesoil

9:45 pm on Sep 21, 2010 (gmt 0)

10+ Year Member



I have cleared the decks many times over the last 3 weeks and before.
I am a daily, nay hourly visitor to W3schools. I have read all the arguements for and against tables recently and in the past. I have watched many youtube tutorials just recently and followed along diligently recreating the code as I go along and thinking "wow how clever am I" and also followed written tutorials aswell, only to go away and try to implement what I have learned and failed to the point that it has made me ill and my eyes have gone square. I do think learning css is the way forward and I feel I have already learned a lot but not enough to make a page work successfully at this time. I am sorry if I misrepresented myself by saying "I don't want an easy ride" because after all the effort and hours that I have put in these last few weeks glued to this pc that is EXACTLY what I am looking for but I am obviously looking in the wrong place. I thank you for your input but tables are what I shall be using at this moment in time until I have learned sufficient css to fly solo. As for the script, I suppose I will carry on and try every which way but loose to get the d**n thing in the right place and you never know some kind soul might come along and just guide me in the right direction. One can only but live in hope.

johnblack

11:01 pm on Sep 21, 2010 (gmt 0)



Not necessarily what you want to hear, but is html above copied directly from the page? If it is, it's invalid.

E.g.

<table width="750" border="0" bordercolor="purple" cellspacing="0" cellpadding="0" align="center">

<tr>
<td height="5" colspan="3" bgcolor="#9AB1C1"> Test<br>
<img src="images/test.jpg">
<tr><td bgcolor="#9AB1C1"><a href="index.htm"> Home</a></td

You start a row with a table cell but neither have closing tags before you start the second table row?

Not sure if fixing it up is going to help you, but it's probably a good place to start.

Major_Payne

11:45 pm on Sep 21, 2010 (gmt 0)



@johnblack: Looks like he used a nested table which is allowed. The errors are a result of using some attributes that are not allowed and other because the shorttags are being used for tags which have no closing tag under the document type used.

caffinated

2:47 am on Sep 22, 2010 (gmt 0)

10+ Year Member



It is a little bit tricky trying to see where you're wanting to get to. You say you can't get the image script positioned inside your table but it is positioned inside your table, so I guess the key word here is "correctly" but you haven't described what "correctly" means. I have noticed a couple of things that might make a difference. The td that contains the photo div is specified as a width of 300 but in the CSS your photo div is specified as 400px. Moreover, one of the images you're trying to show in the demo is actually 640px wide. Is this perhaps where your problem lies? Should you first be making all your images 300px wide in your image editor, then specifying the .photo div as 300px wide? If you did that, you may find your layout gives you the result you want - just perhaps.

You also seem to have a missing '>' on
<tr><td bgcolor="#9AB1C1"><a href="index.htm"> Home</a></td


Hope this gets you out of your immediate pickle but really do have a good look at the above advice about tables. Persevere, it's worth it.

If you've not been before, this is a good css learning resource:
[csszengarden.com ]

Good luck.

Major_Payne

4:31 am on Sep 22, 2010 (gmt 0)



Might work for you, but modify as you see fit:
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title></title>

<meta name="created" content="Wed, 22 Sep 2010 03:02:05 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="PayneLess Designs">
<meta name="copyright" content="Jan 2004 to present.">

<style>
* { margin: 0; padding: 0; border: 0; }

.photos {
width: 400px;
margin: 0 auto;
overflow: hidden;
/* border: 0 solid #f0f0f0; */
/* padding: 10px; */
}

/* img { border: none;} */

.photos img.logo {
width: #*$!px;
height: YYYpx;
margin: 0 auto;
display: block;
}

.photos div img {
float: left;
/* padding: 10px 0; */
/* margin: 20px 0;
border-bottom: 1px solid #ddd; */
}

.photos ul.thumbs li {
float: left;
padding: 0 0 0 10px;
list-style: none;
width: 390px;
}

.photos ul.thumbs li {
float: left;
width: 60px;
height: 100px;
/* margin: 0 10px 0 0; */
margin: 2%;
overflow: hidden;
/* position: relative; */
border: 5px solid #ddd;
text-align: center;
}

.photos ul.thumbs li:hover {
border: 5px solid #888;
-moz-opacity:.75;
filter:alpha(opacity=75);
opacity:.75;
}

.photos ul.thumbs li img {
position: absolute;
top: -180px;
left: -145px;
}

table#main {
width: 800px;
margin: 0 auto;
border-collapse: collapse;
text-align: center;
background: #9ab1c1;
}

caption {
font-size: 2em;
background: #9ab1c1 url(images/test.jpg) no-repeat center scroll;
}

thead {
font-size: 1.25em;
background: #9ab1c1;
}

caption, thead {
font-family: garamond, verdana; 'times new roman', sans-serif;
color: #fff;
}

tfoot {
height: 2em;
background: #9ab1c1;
}

/* tbody td { height: 300px; overflow: auto; padding: 15px; border: 1px solid #ff0; } */
tbody {
width: 100%;
text-align: justify;
}

td#one {
height: 300px;
}

table#two {
width: 100%;
height: 296px;
/* border="0" bordercolor="yellow" */
/* margin: 7px; */
background: #c3e1ec;
}

table#two td {
width: 300px;
vertical-align: top;
text-align: center;
}

table#two td#text {
width: 500px;
text-align: justify;
}

table#two td#nav {
width: 150px;
height: 50px;
vertical-align: top;
text-align: center;
}
</style>

<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<link rel="stylesheet" type="text/css" href="site_css/css_2010_iestyle.css">
<script type="text/javascript" src="site_js/js_blink4IE.js"></script>
<![endif]-->
</head>
<body>
<table id="main">
<caption>Test <a href="index.htm" title="Home">Home</a></caption>

<thead>
<tr>
<th>HEADER</th>
</tr>
</thead>

<tfoot>
<tr>
<td><h3>FOOTER</h3></td>
</tr>
</tfoot>

<tbody>
<tr>
<td id="one">

<table id="two">
<tr>
<td rowspan="3">
<div class="photos">
<div id="photo_1"><img src="images/jumper1_1.jpg" alt=""></div>
<div id="photo_2" style="display:none;"><img src="images/jumper1_2.jpg" alt=""></div>
<div id="photo_3" style="display:none;"><img src="images/jumper1_3.jpg" alt=""></div>
<ul class="thumbs">
<li><a href="javascript:void(0)" onclick="switch_product_img('photo_1', 3);"><img src="images/jumper1_1.jpg" alt=""></a></li>
<li><a href="javascript:void(0)" onclick="switch_product_img('photo_2', 3);"><img src="images/jumper1_2.jpg" alt=""></a></li>
<li><a href="javascript:void(0)" onclick="switch_product_img('photo_3', 3);"><img src="images/jumper1_3.jpg" alt=""></a></li>
<li><a href="javascript:void(0)" onclick="switch_product_img('photo_3', 3);"><img src="images/jumper1_3.jpg" alt=""></a></li>
</ul>
</div>

<script type="text/javascript">
function switch_product_img(divName, totalImgs) {
for (var i=1; i<=totalImgs; i++) {
var showDivName = 'photo_' + i;
var showObj = document.getElementById(showDivName);
if (showDivName == divName)
showObj.style.display = 'block';
else
showObj.style.display = 'none';
}
}
</script>

<p><a href="http://www.sohtanaka.com/web-design/css-multiple-image-viewer-thumbnails/" title="Multiple Image Viewer by Soh Tanaka">Multiple Image Viewer</a><br>by Soh Tanaka</p>
</td>

<td id="text"><p>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.</p>
</td>

<td id="nav"><h2>NAVIGATION</h2></td>
</tr>
</table>

<td>
</tr>
</tbody>
</table>
</body></html>

homesoil

5:13 pm on Sep 22, 2010 (gmt 0)

10+ Year Member



johnblack - Thank you for looking.

caffinated - "but you haven't described what "correctly" means"
I actually did say in my OP where I wanted the positioning, (all I want to achieve is the image viewer far left, the page text centered and the navigation on the right!) but you are right about making the pictures the correct size before I worked with the images. It is something I should have done.

Major_Payne - Not that it matters but I am a she. Thank you for your last post. I will let you know if I can get it to work for me!

Major_Payne

5:41 pm on Sep 22, 2010 (gmt 0)



Major_Payne - Not that it matters but I am a she.
Determining gender by UserNames is hard. Your Profile didn't specify, but as said, it really doesn't matter.

(all I want to achieve is the image viewer far left, the page text centered and the navigation on the right!)
I justified the text, but it may not be as centered on the page as you want as I didn't have the images to put in place and compensate for them if need be. Viewer is left; Navigation is right. May not be exact, but you can change as needed since I kept the (ugh :P) tables.

futureX

12:56 pm on Sep 23, 2010 (gmt 0)

10+ Year Member



As stated, tables are no longer used for page layouts. They went out in the late 1990s with the use of CSS. The web standards are changing again and you need to quit being 10 years plus behind the times like Micro$oft and IE. Tables are still used to present tabular data which was their intended use.
I'll be honest, there are plenty of projects where I've used tables for layout still. Even with IE7/8/9 there are still a lot of things which do not display correctly Vs. other correct browsers and tables can bridge the gap between older browsers and new ones. And yes I am lazy.

I've been hearing "Tables are only for tabular data" for a decade and I still don't see what relevance that has to a layout using tables if it works and displays the same in all browsers. I guess it's the same crowd that were telling me that all new websites after 2000 should be xhtml but I've only recently been switching to it from from HTML 4 Transitional...

Sorry for the rant, but I've never seen a problem that was caused by using tables for layout, if someone can educate me as to exactly what drawbacks there are I'm all ears, maybe I'm just uneducated.

:)

futureX

12:56 pm on Sep 23, 2010 (gmt 0)

10+ Year Member



Edit: Ooops, double post, please delete.

Major_Payne

5:15 pm on Sep 23, 2010 (gmt 0)



@futureX: That was the problem with everybody quickly adopting tables as a layout method. Bad habits for decades has been ingrained into them now and it is hard to break the habit. Tables have ALWAYS been for tabular data from day one. It was just that people found out they could make a page layout with them and browsers parsed them as such.

No problem with tables in ANY browsers for layouts if you use CSS with them. Browsers DO NOT need tables to parse a properly coded page today. Anyone using really outdated browsers are already asking for trouble and need to update for at least security reasons.

The web standards have evolved and the older web pages only work today because web developers insist on making any new version backwards compatible. Once they stop this nonsense, people will be forced to make their pages as they should be made and this should eliminate the problems of browsers parsing pages their own way and you having to compensate for those browser differences. Of course, I know this will never happen as the consequences of millions of broken web sites would be devastating. Just would be nice if all browsers and web sites were "on the same page".

The web standards are just recommended standards after all and this is always going to be a problem with different browsers. The new standards are slowly being included in browsers and Opera is the only one that fully supports them. Others, like Firefox, support the new standards only partially as the developers are probably waiting for them to be finalized. Still, using tables is outmoded, but if you are lazy and don't care to learn how to "code properly", then continue to use them. HTML 4.01 and CSS 2.01 are not hard to learn. Neither is HTML 5.0 and CSS 3.0.

Ron

homesoil

4:08 pm on Sep 26, 2010 (gmt 0)

10+ Year Member



Well I failed miserably despite your attempts to help me. I was never that brilliant at html before I tried to learn CSS but I keep going and I have produced my website albiet with as many "workarounds" as it took.
I am pleased with it considering where I was a few days ago.
We all learn at different speeds and I have used aspects of css in my pages which I am proud of. The rest will come later but I might be too old by then. Maybe I'll make enough money from my site where I can pay someone else to do it in the future :) (yeah right!)
Anyway thanks again and here are results so far.
www.yankeeclobber.com

Major_Payne

4:00 am on Sep 27, 2010 (gmt 0)



You're welcome. Your site is nice and quick getting around. May change when you flesh it out. Just, please, remember to validate the CSS and HTML code. Many of the HTML errors are minor ones.

I hope I didn't mess you up by using an HTML 5 doctype or anything. If I had the full images, I could have done a better job. Anyway, good luck.

Ron