Click to See Complete Forum and Search --> : Great in FF, OK in IE7, Awful in IE6.


invision
07-27-2008, 07:23 AM
Hi,

I'm going to guess this is probably one of those simple but niggly problems people come across when CSS and IE6 are in the same room :lol:

OK, so this page http://www.farawaytrains.co.uk/scotland/ looks as I want it to in FF, Safari, Opera. Just have two issues...

1) In IE7, the right-hand column(rightbar element in my CSS) seems to cut off the text early at the foot, for some odd reason.
2) In IE6, it seems to try to repeat the container element background for a bit, even though I have restricted it to 444px. Why does this happen?

I've attached screen-grabs to illustrate my errors.

http://www.farawaytrains.co.uk/scotland/css/styles.css - stylesheet

Many thanks for any suggestions or advice with this, been a head-scratcher for a few days now.

WebJoel
07-27-2008, 08:39 AM
I think I know the problem, -but I'm on the Linux side today and my testing tools over on XP-side. I'll examine this later today. It is a small problem, nothing more. :)

Centauri
07-27-2008, 10:52 AM
Same problems as the other similar layout you PM'd me about. Setting the height of anything that contains an amount of text is doomed to failure - increase the text size and the text overhangs everything. IE6 only treats height as min-height anyway, so it will always try to expand the container to fit content, whether you have a height set of not. The other issues are the large negative margins trying to overlay the column content on top of the background divs - these background divs (which may have opacity set, for the benefit of other posters looking at this) would be better defined at the start of the container div and absolutely positioned and set to 100% height. The content will then overlay them naturally if a z-index is set. The container and its children should then be allowed to find their own height, though you can set a minimum height.

invision
07-27-2008, 01:15 PM
Hmm...that does sound a bit complicated. So I'd be starting over?

Could you perhaps show me the best way to do this? Hate to be a pain but I'm getting a bit confused by which option is best and how to implement them.

So I should drop all negative margins and ALL height declarations, except for the main 'container' element?

invision
07-27-2008, 02:27 PM
OK. Firstly, many thanks for your patience with this.
http://www.farawaytrains.co.uk/scotland/index2.html have removed the surrounding DIVs as suggested and it's looking better in all the browsers.

Unfortunately, I no longer have the background opacity effects.

Where should I go from here?

Centauri
07-27-2008, 07:00 PM
Would like to clarify what you are after here. At the moment, the side panels have solid grey and red backgrounds, so I don't see the point of a semi-transparent layer over the top of them. Is the container background image eventually going to be full width or something? - then the translucent layers would make sense.

invision
07-28-2008, 01:02 AM
Hi Centauri,

The idea is that it would eventually look like this page (http://www.farawaytrains.co.uk/scotland/) across all FF, IE7 and IE6. Right now that page(with the opacity/alpha bits) only works well in FF and IE7), so I need to find a workaround.
Yes the main 'container' element will store a full 899px width image and translucent layers will be on either side as shown in the above link.
I just put in red and grey for testing to see where the <div>'s ended.

Centauri
07-28-2008, 06:47 AM
The grey and red backgrounds were throwing me as it was difficult to see the transparency. I quickly located the original photo of Dunollie Castle you used, and when resized to 900px wide, it is 675px high, and when centred on the background of the main content div, gives a fair margin of expansion, thus the locked height (and associated problems with that) can be dispensed with and the site can vary with text size and content.

Getting the transparency filter to work in IE can be tricky, as HasLayout needs to be triggered on the element the filter is applied to (in both IE6 and IE7). A size (height or width) will trigger HasLayout, but this is not always possible or desired. Min-height will trigger HasLayout in IE7 but not IE6, and has no adverse effects in other browsers. As IE6 treats height like min-height, feeding IE6 height via a star-html hack works fine.

I rehashed the html, reducing the number of containers required, and used more descriptive id and class names to make things easier to follow. The html I came up with is :<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Scotland - A tribute...</title>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<ul id="navtop">
<li><a href="#">#</a></li>
<li><a href="#">#</a></li>
<li><a href="#">#</a></li>
<li><a href="#">#</a></li>
<li class="last">Tel / Fax : </li>
</ul>
<div id="content">
<div id="leftmask"></div><div id="rightmask"></div>
<div id="rightcol">
<h2>Introduction</h2>
<div id="rightpanel">
<p>Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum </p>
<p>Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsumLorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</p>
<p>Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum.</p>
</div>
</div>
<div id="leftcol">
<ul id="navleft">
<li><a href="#">Home</a></li>
<li><a href="#">Info</a></li>
<li><a href="#">History</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Guestbook</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div id="leftpanel">
<p>Some other stuff here</p>
</div>
</div>
</div>
<p id="subfoot">Tel / Fax :</p>
<div id="footer">
<p>Site info</p>
</div>
</div>
</body>
</html>
The translucent overlays either side are done with the #leftmask and #rightmask divs. Note that these divs are the first thing inside the #content div - they can be absolutely positioned either side of #content and can be made 100% height of #content no matter how high #content is pushed by its child elements. The #leftcol and #rightcol divs can then be floated left and right, and will overlay on top of the translucent panels. These divs don't then need to extend full height - the translucent panels act as faux columns (in fact, this method of absolutely positioning 100% height background elements is one of the methods of producing faux columns).

Css next post.

Centauri
07-28-2008, 07:15 AM
The css file I used for this is :* {
margin: 0;
padding: 0;
}
body {
background-color: #FDFDFD;
color: #333333;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
p {
margin-bottom: 1em;
}
#wrapper {
width: 900px;
margin: 30px auto 0;
}
#navtop {
height: 25px;
background-color: #344233;
text-align: center;
position: relative;
}
#navtop li {
list-style: none;
display: inline;
}
#navtop .last {
color: #FFFFFF;
padding-left: 10px;
}
#navtop a {
color: #FFFFFF;
text-decoration: none;
line-height: 25px;
padding: 0 15px;
}
#navtop a:hover {
font-weight: bold;
}
#content {
position: relative;
background-image: url(images/bg.jpg);
background-repeat: no-repeat;
background-position: center;
overflow: hidden;
background-color: #A49C9A;
}
* html #content {
height: 300px;
overflow: visible;
}
#leftmask {
position: absolute;
width: 240px;
height: 100%;
filter: alpha(opacity=50);
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
background-color: #FFFFFF;
left: 0px;
top: 0px;
}
#rightmask {
position: absolute;
width: 240px;
height: 100%;
background-color: #FFFFFF;
filter: alpha(opacity=50);
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
right: 0px;
top: 0px;
}
* html #rightmask, * html #leftmask {
height: expression(document.all['content'].clientHeight);
}
#rightcol {
float: right;
width: 210px;
position: relative;
margin-right: 15px;
display: inline;
padding: 10px 0;
}
#rightcol h2 {
font-size: 130%;
text-align: center;
margin-bottom: 5px;
}
#rightpanel {
min-height: 350px;
}
#rightpanel, #rightcol h2, #leftpanel {
background-color: #FFFFFF;
color: #000000;
padding: 6px;
border: 1px solid #666666;
filter: alpha(opacity=60);
-moz-opacity:0.6;
-khtml-opacity:0.6;
opacity:0.6;
min-height: 10px;
}
* html #rightcol h2, * html #leftpanel {
height: 1%;
}
* html #rightpanel {
height: 350px;
}
#leftcol {
float: left;
width: 210px;
position: relative;
margin-left: 15px;
display: inline;
padding: 10px 0;
}
#navleft {
margin: 20px 0;
}
#navleft li {
list-style: none;
margin-bottom: 5px;
}
#navleft a {
display: block;
height: 33px;
line-height: 33px;
text-align: center;
text-decoration: none;
color: #000000;
border: 1px solid #666666;
background-color: #FFFFFF;
filter: alpha(opacity=60);
-moz-opacity:0.6;
-khtml-opacity:0.6;
opacity:0.6;
}
#navleft a:hover {
filter: alpha(opacity=100);
-moz-opacity:1;
-khtml-opacity:1;
opacity:1;
}
#subfoot {
background-color: #344233;
color: #FFFFFF;
height: 25px;
line-height: 25px;
padding-left: 14px;
font-weight: bold;
}
#footer {
margin-top: 40px;
text-align: center;
}

The css is fairly self-explanatory and similar to yours down the the #content div, apart from the top navigation <ul> being styled directly instead of being contained in a div.

The #content div gets the background image centred vertically, and an appropriate background colour assigned in case the div expands past the height of the image. It also gets a relative position to provide the reference for the absolutely positioned translucent panels, and overflow set to force it to surround the internal floats. As IE6 does not understand the overflow method, it is fed an arbitrary height to trigger HasLayout, and the overflow reset - this height setting (which IE6 treats like min-height) is also required to make the height expression work for setting the translucent panels height in IE6 - mentioned shortly).

The two mask divs are sized and absolutely positioned to the left and right of the content div, and given the required transparency. The 100% height will work in modern browsers (even IE7), but not for IE6, so an expression is used to calculate the height and fed to IE6 via another star-html hack. This expression will only work if the parent div it refers to has a height set, even if this is expanded by content, hence the height referred to earlier.

The #rightcol and #leftcol divs are floated right and left, and given the width and appropriate side margin to centre them in the translucent panels. The relative position is to ensure they overlay on top of the translucent panels, and the inline display quashes IE6's doubled float margin bug.

The #rightpanel, h2 and #leftpanel are given their transparency, and a min-height to trigger HasLayout in IE7. The #rightpanel is given a 350px min-height, and it is this that sets the overall minimum height of the site if there is little content. All three of these elements are given a height to IE6 through more star-html hacks to trigger HasLayout.

The left navigation has the <a> elements sized, coloured, and transparency applied, with spacing between them done with a bottom margin on the <li>s. I also included a non-translucent rollover style for these.

See if this is close to what you were doing. This can also all be directly applied to the upholstery site you are doing.

invision
07-28-2008, 08:43 AM
Once again, I bow before you oh lord of CSS.

Really can't thank you enough for the help you've given.

And some brilliant explanations for the changes too.

Good call in keeping the two masks at the head of the container.

Code is less cluttered, more clear and much more manageable.

It works perfectly and I plan to look over the brilliant code you've made up.


Many thanks once more.