CSS layout combining fixed and relative elements

Posted on 2013-05-17
Last Modified: 2013-11-19
Hi experts,

I am trying to build a page with a fixed left menu and then products' columns.

I have success, everything works well except :
In Firefox, the background ends below my header (with navigation bar), include my footer, but the main body is uppon all.

In Chrome, Safari, Opera & even in IE it works well, like I wish.

Do you have an idea wtf is this bug ?

You can view the online version HERE

Here are the page products:
<div id="products">
	<cfif variables.viewType.mode EQ "details">
	<cfelseif variables.viewType.mode EQ "thumbs">
		<!--- variable to hold table layout --->
		<cfset variables.columnCounter = 0> <!--- variable to hold columns layout --->
		<cfif session.productsColumns GT 1>
			<cfset variables.columnwidth = 100 / session.productsColumns> <!--- variable to hold columns width --->
			<cfset variables.productswidth = variables.columnwidth * (session.productsColumns - 1)> <!--- variable to hold products part width (without sideBar) --->
			<cfset variables.columnwidth = 50>
			<cfset variables.productswidth = variables.columnwidth>
		<!--- display side Bar & productsThumbs --->
			<!--- display the side bar --->
			<div id="productsSideBar" style="width:#variables.columnwidth#%;"> <cfinclude template="/views/sharedComponents/3a_productsSideBar.cfm"> </div>
			<!--- display the products --->
			<div id="productThumbs" style="width:#variables.productswidth#%;">
					<cfloop array="#variables.products#" index="variables.product">
						<cfset variables.columnCounter ++>
						<cfif variables.columnCounter EQ 1> <tr> </cfif>
							<td class="productThumb" style="width:#variables.columnwidth#%;">
								<!--- the product's picture --->
								<a href="#request.targetCFC.getUrl()#" class="productsLinks" onclick="processing();">
									<img class="productThumbPicture" src="" />
								</a> <br/>
								<!--- products data --->
								<div class="productThumbData">
									<!--- data always displayed --->
									<div class="productThumbDataAlwaysDisplayed">
										#variables.product.getReferenceId()# #variables.product.getName()# <br/>
										Packsize #variables.product.getPacksize()# #variables.product.getAssortmentType()# <br/>
										#session.currency# #evaluate("variables.product.get" & variables.priceActive & "()")# <br/>
									<!--- data displayed on hover --->
									<div class="productThumbDataDisplayedOnHover">
										<input type="button" class="productsButtons"			value="#request.targetCFC.getRangeLabel()#"
																							onclick="processing();document.location.href='#request.targetCFC.getUrl()#';"> <br/>
										<input type="button" class="productsButtons"			value="#request.targetCFC.getMoreDetailsLabel()#..."
										<input type="button" class="productsButtons submit"	value="#request.targetCFC.getAddToBasketLabel()#"
																							onclick="processing();document.location.href='#request.targetCFC.getUrl()#';"> <br/>
						<cfif variables.columnCounter EQ session.productsColumns - 1>
							<cfset variables.columnCounter = 0>
					<cfif variables.columnCounter NEQ 0>
						<cfloop condition="variables.columnCounter NEQ 0">
							<cfset variables.columnCounter ++>
							<td class="productThumb">&nbsp;</td>
							<cfif variables.columnCounter EQ session.productsColumns - 1>
								<cfset variables.columnCounter = 0>

Open in new window

And here is the css involved:
@charset "UTF-8";
/* Contains the css's rules for the global website's parts */

*** Products' parts - General elements ***
/* the div containing the products (all, the page body +/-) */
#products {
/* the links surrounding products' pictures */
.productsLinks {
/* the products' buttons */
.productsButtons {
	float: none;
*** END Products' parts - General elements ***

*** Products' parts - Thumbs ***
/* the part containing the products' side bar */
#productsSideBar {
	float: left;
	position: fixed;
/* the part containing the products thumbs */
#productThumbs {
	float: right;
/* the td containing 1 product thumb (data + image) */
.productThumb {
	text-align: center;
	vertical-align: bottom;
	padding-bottom: 3em;
/* the product's picture */
.productThumbPicture {
	text-align: center;
/* the div containing product's data - all */
.productThumbData {
	text-align: left;
/* the div containing product's data - always visible data */
.productThumbDataAlwaysDisplayed {
/* the div containing product's data - visible on hover data */
.productThumbDataDisplayedOnHover {
	visibility: hidden;
/* the div containing product's data - visible on hover data - hover attributes */
#productThumbs td:hover .productThumbDataDisplayedOnHover {
	visibility: visible;
*** END Products' parts - Thumbs ***

Open in new window

Thanks a lot for your help.
Question by:adam1h
  • 2
LVL 53

Expert Comment

ID: 39176390
The page is junk in all browsers.  There are 93 validation errors; many of them serious.  

The immediate issue is because you have not set a background color on the menu or main content.  Firefox followed the xhtml spec and defaulted the background to transparent.  The other browsers probably don't have a problem because the defective code likely confused them and they rendered wrong and the combination of bad code and weak browser compliance worked in your favor.  

If you leave the page code the way it is, it is going to be unstable and every time you touch it is could just meltdown.

LVL 15

Accepted Solution

Jagadishwor Dulal earned 500 total points
ID: 39176557
Yes there is few errors in your style. As you are productsSideBar and productThumbs two column floating why didn't you clear floating before your footer start.

I have tested using inline style:

<div style=" clear:both;"></div>
<div id="footer">

Open in new window


Author Comment

ID: 39176813
Hi both,

Thanks To point this to me.

I'll try to repair these errors and to add the clear:both; code.

Author Comment

ID: 39185825
Hi Both,

Sorry for late replying.

It works well when adding "clear: both;" to the footer.

With wich tool do you see the error validation ?

I have check with firebug but I see nothing.


Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
This video teaches users how to migrate an existing Wordpress website to a new domain.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now