Forum Moderators: mack

Message Too Old, No Replies

IFrame Positioning

How to ensure positioning across browsers

         

jaguarette

12:47 am on Dec 15, 2003 (gmt 0)

10+ Year Member



I've created the code for an IFrame that appears in the top right hand corner of the screen... but only in NS 7.1. I can't see why it doesn't appear in the right place in Opera 7.11 or IE 6. I haven't tried in earlier browsers, as I would have checked them after I was sure it worked across the newer ones.

I've written the code in Notepad, and have checked it against W3C validators.

The style sheet (external) is
_____________________
div.index {width:20%;
position:absolute;
color: rgb(0,160,255);
font-family: sans-serif;
font-weight:bold;
font-size:large;
font-style:italic;}

div.normal {width:100%;
line-height:0.6}
_____________________

and the HTML is
_____________________
<BODY>
<DIV class="index"><P>Front Page<BR><BR>Latest Pictures<BR><BR>Gallery<BR><BR>Birth Statistics</P></DIV>

<iframe class="normal" align="right" position="absolute" height=75% width=80% top=0 src="http://www.google.co.uk">

</iframe>
<DIV class="normal">
<P><img src="images/name.gif"> <img src="images/email.gif"</P></DIV>

</BODY>
</HTML>
_____________________

Please could someone suggest some easy cross-browser fix? Or at least an attempt to make it work?

Thanks

iamlost

2:07 am on Dec 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld jaguarette!

Your positioning problem is that you have a conflict between your iframe html code requiring a width of 80% and your css .normal class requiring a width of 100%.

For whatever reasons NN7.1 is allowing the html to override the css and the others are not.

Change .normal to width: 80%;

jaguarette

3:10 am on Dec 15, 2003 (gmt 0)

10+ Year Member



Thanks for the welcome! Following your suggestion, I changed .normal. There was no difference to the display, except that I got a 1-dimensional iframe in IE.

I've now changed a few bits on the codes, including entering them into a table... and I have different and still wrongly placed renditions! And they're all different. Perhaps they'll be clearer tomorrow, after some sleep (3am here).

Nothing changed on the CSS.
Thanks
Jaguarette
_________________________
<BODY>
<TABLE width="100%">
<TR height="80%" width="20%">
<TD><P><DIV class="index">Front Page<BR><BR>Latest Pictures<BR><BR>Gallery<BR><BR>Birth Statistics</DIV></P>
</TD>
<TD><IFRAME class="normal" src="http://www.google.co.uk"></IFRAME>
</TR>
<TR>
<TD> hi</TD>
<TD> <img src="images/name.gif"> <img src="images/email.gif"</P></TD>
</TR>
</TABLE>
</BODY>
_________________________

iamlost

5:45 am on Dec 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The 1-dimension iframe in IE is because you have no specified height. If you give your iframe a fixed height i.e. 100px, you will see your iframe. IE does the same 1-dimensional thingy (love these tech terms!) when you use percentages too.

Your table re-design is something of a mish-mash. You may want to try using divs such as below:

CSS:


html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
div#index {
position: absolute;
left: 0;
top: 0;
width: 20%;
height: 100%;
color: rgb(0,160,255);
font: italic bold large sans-serif;
text-align: center;
border: none;
}
div#index p {
margin: 20px 0 0 0;
padding: 0;
}
div#index a {
text-decoration: none;
}
div#frame, div#image {
float: right;
width: 80%;
left: 20%;
margin: 0;
padding: 0;
border: none;
line-height: 0.6;
}
div#frame iframe {
width: 100%;
height: 100%;
margin: 10px 0 0 0;
padding: 0;
line-height: 0.6;
border: 1px black solid;
}
div#image img {
width: 50px;
height: 50px;
padding: 0;
margin: 10px;
border: none;
{

HTML:


<!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" xml:lang="en" lang="en">
<head>
<title>Test Bed</title>
<link href="test.css" rel="stylesheet" type="text/css" />
</head>
<body >
<div id="index">
<p><a href="x">Front Page</a></p>
<p><a href="x">Latest Pictures</a></p>
<p><a href="x">Gallery</a></p>
<p><a href="x">Birth Statistics</a></p>
</div>
<div id="frame">
<iframe src="http://www.google.co.uk"></iframe>
</div>
<div id="image">
<img src="dog.jpg" height="50px" width="50px" alt="" /><img src="dog.jpg" height="50px" width="50px" alt="" />
</div>
</body>
</html>

In my testing I changed your classes to id's. This is somewhat personal preference and somewhat how often a div will be used in a page (id's once, classes multiple).

Hopefully the above will give you somethings to consider and help get your design working as you want.

jaguarette

11:45 pm on Dec 15, 2003 (gmt 0)

10+ Year Member



Thanks for your help. The divs have worked cross browser (across NS7.1, IE6, and Opera 7.11 anyway). My images didn't work at 50px2, so I removed the height/width declarations from CSS and it worked in NS7.1 and IE, but appeared S..T..R..E..T..C..H..E..D.. way too much in Opera. So then I CSSed the height as 60px... and crashed Opera! it crashed again when I tried the height at 20px (the image doesn't change, but the browser crashes). Go figure!

Anyway, your advice was spot on & I now have a cross-browser CSS sheet. Can you recommend anywhere I can reread the logic of CSS? Like I said, I've read all about it at W3C, and I've been reading webmonkey and other sites, but I haven't captured the feel of it the way you obviously have:).

Thanks - Jaguarette