homepage Welcome to WebmasterWorld Guest from 54.205.254.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
Links not working in Firefox
majorgoals




msg:4303211
 6:12 am on Apr 24, 2011 (gmt 0)

I am new to your forum and hope you can help me solve a problem I am having with my coding for my web page. In Firefox everything works and looks the way I had hoped it too but the links in both sidebars do not work. The navbar works fine. I was at my wits end when I discovered that I potentially have an expanding box problem (I think). I inserted overflow: auto in the #maincontent div and it messed up the main content causing it to form a very skinny column down the page, but guess what, the links worked. I am not sure where to start to resolve the issue and was hoping someone could look at my html and css and point me in the right direction. Thanks in Advance.

HTML
_____________________________

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

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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home Garden Workshop</title>
<link href="ThreeColLiqLtHdr.css" rel="stylesheet" type="text/css" />

<!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.ThreeColLiqLtHdr #sidebar1 { padding-top: 30px; }
.ThreeColLiqLtHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->

<style type="text/css" />

<!--
.image{
border-style:outset;
border-color:red;
border-width:10px;
}

.quote{
border-style:groove;
border-color:navy;
border-width:15px;
}

body {
background-color:#F3F7F2;
} -->
<!-- end of #style -->
</style>

<!-- end of #head -->
</head>

<body bgcolor="#295E3D" class="ThreeColLiqLtHdr">

<div id="container">

<div id="header">
<h1><img src="images/Homegarden.gif" width="100%" height="152" alt="Home Garden Workshop" /></h1>
<!-- end of #header div -->
</div>

<div id="navbar">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="welcome.html" title="Welcome">Welcome</a></li>
<li><a href="feedback.html">Feedback</a></li>
</ul>
<!-- end of #navbar div -->
</div>

<div id="sidebar1">
<div id="news">
<h2>HOT TOPICS</h2>
<h3>04/20/11</h3>
<p><a href="chickens.html">Chickens in the Yard</a>.</p>
<div class="hr-dots"> </div>
<!-- end of news div -->
</div>
<!-- end of #sidebar1 div -->
</div>

<div id="sidebar2">
<script type="text/javascript"><!--
google_ad_client = "pub-123";
/* Sidebar2_top_120x240, created 3/12/11 */
google_ad_slot = "123";
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- end of #sidebar2 div -->
</div>

<div id="mainContent">
<h1>Teach Our Children to Garden</h1>
<p><img src="images/burg.jpg" alt="A typical meal." width="162" height="129" hspace="10" align="left" />Example text.</p>

<h3>Key Findings:</h3>
<ul>
<li>Example text.</li>
<li>Example text.</li>
<li>Example text.</li>
</ul>

<h3>Conclusion:</h3>
<p>Example text.</p>
<p>Example text.</p>
<p>Example text.</p>

<!-- end of #mainContent div -->
</div>

<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<br class="clearfloat" />

<div id="footer">
<p>Copyright 2010-2011</p>
<!-- end of #footer div -->
</div>

<!-- end of #container div -->
</div>

<!-- end of #body div -->
</body>
</html>


CSS
____________________________________

@charset "utf-8";

body {
font: 90% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: justify; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}

#navbar {
width: 100%;
float: left;
margin: 0 0 1em 0;
padding: 0;
background-color: #F3F7F2;
border-bottom: 1px solid #ccc;
}

#navbar ul {
list-style: none;
width: 100%;
margin: 0 auto;
padding: 0;
}

#navbar li {
float: left;
}

#navbar li a {
display: block;
height: 9%;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #0B615E;
border-right: 1px solid #ccc;
}

#navbar li:first-child a {
border-left: 1px solid #ccc;
}

#navbar li a:hover {
color: #c00;
background-color: #fff;
}

.ThreeColLiqLtHdr #container {
width: 60%; /* this will create a container 50% of the browser width */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 2px solid #0B615E;
text-align: left; /* this overrides the text-align: center on the body element. */
}

.ThreeColLiqLtHdr #header {
background: #DDDDDD;
padding: 0px 0px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
}

.ThreeColLiqLtHdr #header h1 {
margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
padding: 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
border: 1px solid #FFFFFF;
}



/* Tips for sidebar1:
1. since we are working in percentages, it's best not to use padding on the sidebar. It will be added to the width for standards compliant browsers creating an unknown actual width.
2. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".twoColLiqLtHdr #sidebar1 p" rule.
3. Since Explorer calculates widths after the parent element is rendered, you may occasionally run into unexplained bugs with percentage-based columns. If you need more predictable results, you may choose to change to pixel sized columns.
*/

.ThreeColLiqLtHdr #sidebar1 {
float: left;
width: 20%; /* since this element is floated, a width must be given */
background: #FFFFFF; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 0px 0px; /* top and bottom padding create visual space within this div */
}

.ThreeColLiqLtHdr #sidebar1 h2, .ThreeColLiqLtHdr #sidebar1 h3, .ThreeColLiqLtHdr #sidebar1 p {
margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 10px;
}

#news {
padding-left: 15px;
padding-right: 20px;
padding-bottom: 3px;
text-align: left;
}
#news h2 {
font-size: 12px;
color: #0B615E;
text-align: center;
}
#news h3, #news p {
font-size: 11px;
margin: 1em 8px 1em 0;
}
#news a {
color: #74653D;
font-weight: bold;
text-decoration: underline;
}
#news a:hover {
color: #38301A;
}
#news .more {
font-size: 9px;
}
#news .hr-dots {
background: center url(images/dots.gif) repeat-x;
height: 10px;
}

.ThreeColLiqLtHdr #sidebar2 {
float: right;
width: 15%; /* since this element is floated, a width must be given */
background: #FFFFFF; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 0px 0px; /* top and bottom padding create visual space within this div */
}

.ThreeColLiqLtHdr #sidebar2 h3, .ThreeColLiqLtHdr #sidebar2 p {
margin-left: 0px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 0px;
}


/* Tips for mainContent:
1. the space between the mainContent and sidebar1 is created with the left margin on the mainContent div. No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
2. to avoid float drop at a supported minimum 800 x 600 resolution, elements within the mainContent div should be 430px or smaller (this includes images).
3. in the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs.
*/

.ThreeColLiqLtHdr #mainContent {
position:relative;
padding:0px 200px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}

.ThreeColLiqLtHdr #footer {
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
background: #DDDDDD;
}

.ThreeColLiqLtHdr #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
}

/* Miscellaneous classes for reuse */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}

.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 8px;
}

.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear: both;
height:0;
font-size: 1px;
line-height: 0px;
}

[edited by: alt131 at 12:57 pm (utc) on Nov 27, 2011]
[edit reason] Thread Tidy - Examplifying [/edit]

 

alt131




msg:4303254
 10:15 am on Apr 24, 2011 (gmt 0)

Hi Majorgoals and a warm welcome to WebmasterWorld,

I only have time for a quick look, but at first glance I think the problem is #mainContent.

That div is after the sidebars in your source, with the result it is drawn last, or closest to the viewer - which means on top of the sidebars. It is the full width of the container, so the links "don't work" because #mainContent is painted over the top of them, so covers them up. Set a background-color on #mainContent to see this in action.

Probably the easiest fix is to use a margin rather than padding. (Leave the background-color in so you can watch what happens.)
.ThreeColLiqLtHdr #mainContent {
position:relative;
/* delete padding
padding:0 200px; */
/* use margin instead */
margin:0 200px;
font-family: Verdana, Arial, Helvetica, sans-serif;
/* watch what is happening! */
background-color:tan
}

majorgoals




msg:4303716
 6:06 pm on Apr 25, 2011 (gmt 0)

Alt131 - Thanks a lot the idea (use of margins instead of padding), it solved the problem and all the links now work. It opened up a few more issues because it caused the #mainContent to lay over the navbar so I inserted (position: relative; z-index: 1;) in the #navbar and that threw the navbar over the #mainContent (I think) and the navbar is fully functinal again. Now the only thing I have spent the last 6 hours trying to resolve is why the content in the #mainContent will not expand down the page. Instead all the "B's" I typed into my html file are all inline infinitely as many as I type off the right of the page. I have played with floats and clears in the #container because that resolved someone elses problem (I was perusing similar problems in the forum) and that does not appear to be working for me or I have not figured out the right combination. I obviously am missing something and I surely cannot "see visually in my mind" what the problem is. Expanding down the page works in both #sidebars (and yep the links all work thanks to your suggestion). I validated the html and css and solved a couple problems that existed but now am look up to you (in a kneeling position) hoping for a solution to the current hurdle so I can create another one. I am so close and I have got to admit this HTML/CSS stuff is rather exciting (although frustrating at times). What should I try? And once again thanks in advance. Here is the code and .css.

HTML
_______________________________________

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

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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home Garden Workshop</title>
<link href="ThreeColLiqLtHdr.css" rel="stylesheet" type="text/css" />

<!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.ThreeColLiqLtHdr #sidebar1 { padding-top: 30px; }
.ThreeColLiqLtHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->

<style type="text/css">

<!--
.image{
border-style: outset;
border-color:red;
border-width:10px;
}

.quote{
border-style:groove;
border-color:navy;
border-width:15px;
}

body {
background-color:#F3F7F2;
} -->
<!-- end of #style -->
</style>

<!-- end of #head -->
</head>

<body bgcolor="#295E3D" class="ThreeColLiqLtHdr">

<div id="container">

<div id="header">
<h1><img src="images/Homegardenheaderwbee.gif" width="100%" height="152" alt="Home Garden Workshop" /></h1>
<!-- end of #header div -->
</div>

<div id="navbar">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="welcome.html" title="Welcome">Welcome</a></li>
<li><a href="feedback.html">Feedback</a></li>
</ul>
<!-- end of #navbar div -->
</div>

<div id="sidebar1">
<div id="news">
<h2>HOT TOPICS</h2>
<div class="hr-dots"> </div>
<h3>04/20/11</h3>
<p><a href="chickens.html">Chickens in the Yard</a>.</p>
<div class="hr-dots"> </div>
<!-- end of news div -->
</div>
<!-- end of #sidebar1 div -->
</div>

<div id="sidebar2">

<script type="text/javascript"><!--
google_ad_client = "pub-123";
/* Sidebar2_top_120x240, created 3/12/11 */
google_ad_slot = "123";
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

<h2>HOT TOPICS</h2>
<h3>04/20/11</h3>
<p><a href="chickens.html">Chickens in the Yard</a>.</p>
<div class="hr-dots"> </div>

<!-- end of #sidebar2 div -->
</div>

<div id="mainContent">
<h1>Teach Our Children to Garden</h1>
<p><img src="images/burg.jpg" alt="A meal." width="162" height="129" hspace="10" align="left" />Example text.</p>

<h3>Key Findings:</h3>
<ul>
<li>Example text</li>
<li>Example text</li>
<li>Example text</li>
</ul>

<h3>Conclusion:</h3>
<p>Example text.</p>
<p>Example text.</p>
<p>Example text.</p>
<p>Example text.b</p>

<!-- end of #mainContent div -->
</div>

<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<br class="clearfloat" />

<div id="footer">
<p>Copyright 2010-2011 by CEM</p>
<!-- end of #footer div -->
</div>

<!-- end of #container div -->
</div>

<!-- end of #body div -->
</body>
</html>


THE CSS
_______________________________

@charset "utf-8";

body {
font: 90% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: justify; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}

#navbar {
width: 100%;
float: left;
margin: 0 0 1em 0;
position: relative; z-index: 1;
padding: 0;
background-color: #F3F7F2;
border-bottom: 1px solid #ccc;
}

#navbar ul {
list-style: none;
width: 100%;
margin: 0 auto;
padding: 0;
}

#navbar li {
float: left;
}

#navbar li a {
display: block;
height: 9%;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #0B615E;
border-right: 1px solid #ccc;
}

#navbar li:first-child a {
border-left: 1px solid #ccc;
}

#navbar li a:hover {
color: #c00;
background-color: #fff;
}

.ThreeColLiqLtHdr #container {
width: 60%; /* this will create a container 50% of the browser width */

background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 2px solid #0B615E;
text-align: left; /* this overrides the text-align: center on the body element. */
}

.ThreeColLiqLtHdr #header {
background: #DDDDDD;
padding: 0px 0px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
}

.ThreeColLiqLtHdr #header h1 {
margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
padding: 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
border: 1px solid #FFFFFF;
}

/* Tips for mainContent:
1. the space between the mainContent and sidebar1 is created with the left margin on the mainContent div. No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
2. to avoid float drop at a supported minimum 800 x 600 resolution, elements within the mainContent div should be 430px or smaller (this includes images).
3. in the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs.
*/

.ThreeColLiqLtHdr #mainContent {
position: relative;
margin: 0px 200px;
font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #FFF;
}

/* Tips for sidebar1:
1. since we are working in percentages, it's best not to use padding on the sidebar. It will be added to the width for standards compliant browsers creating an unknown actual width.
2. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".twoColLiqLtHdr #sidebar1 p" rule.
3. Since Explorer calculates widths after the parent element is rendered, you may occasionally run into unexplained bugs with percentage-based columns. If you need more predictable results, you may choose to change to pixel sized columns.
*/

.ThreeColLiqLtHdr #sidebar1 {
float: left;
width: 20%; /* since this element is floated, a width must be given */
background-color: #FFF; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 0px 0px; /* top and bottom padding create visual space within this div */
}

.ThreeColLiqLtHdr #sidebar1 h2, .ThreeColLiqLtHdr #sidebar1 h3, .ThreeColLiqLtHdr #sidebar1 p {
margin-left: 0px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 0px;
}

#news {
padding-left: 15px;
padding-right: 20px;
padding-bottom: 3px;
text-align: left;
}
#news h2 {
font-size: 12px;
color: #0B615E;
text-align: left;
}
#news h3, #news p {
font-size: 11px;
margin: 1em 8px 1em 0;
}
#news a {
color: #74653D;
font-weight: bold;
text-decoration: underline;
}
#news a:hover {
color: #38301A;
}
#news .more {
font-size: 9px;
}
#news .hr-dots {
background: center url(images/dots.gif) repeat-x;
height: 10px;
}

.ThreeColLiqLtHdr #sidebar2 {
float: right;
width: 15%; /* since this element is floated, a width must be given */
background-color: #FFF; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 0px 0px; /* top and bottom padding create visual space within this div */
}

.ThreeColLiqLtHdr #sidebar2 h3, .ThreeColLiqLtHdr #sidebar2 p {
margin-left: 0px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 0px;
}


.ThreeColLiqLtHdr #footer {
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
background: #DDDDDD;
}

.ThreeColLiqLtHdr #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
}

/* Miscellaneous classes for reuse */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}

.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 8px;
}

.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear: both;
height:0;
font-size: 1px;
line-height: 0px;
}

[edited by: eelixduppy at 12:06 am (utc) on Apr 26, 2011]

[edited by: alt131 at 12:59 pm (utc) on Nov 27, 2011]
[edit reason] fixed side scroll [/edit]

alt131




msg:4303930
 2:32 am on Apr 26, 2011 (gmt 0)

Fantastic you find this exciting (and are figuring out how to resolve issues as they arise) - and am hoping the "frustrating" times happen when you push up against the limits of your current knowledge - so you might treat them as a great learning opportunity that leads to even more exciting discoveries <-- it's all in the words you use ;)

Taking the issues in turn:
... why the content in the #mainContent will not expand down the page. Instead all the "B's" I typed into my html file are all inline infinitely as many as I type off the right of the page.

The b's don't "wrap" onto a new line because text "breaks" at white space - and there isn't any in a continuous line of "b's".
How to fix? Years ago ie introduced white-space:word-break, which forces unbroken text to "wrap" rather than expanding beyond the edge of the containing block - exactly as you want. It is a proprietary property, not in the css recommendations, but has since been implemented by other browsers, so reasonably safe to use. It has been proposed as an "emergency" way to achieve word wrapping for css3, but that isn't yet a standard so the property will be reported as an error by the validator. Plus it is not really the preferred way to force a break, so the validator will suggest one of the other options such as break-word. I believe that's a reference to the css3 word-break - but if course that isn't yet a standard yet either, plus hasn't been as widely adopted as white-space.
What to do? First, I'd ask why the lines of text have no white-space - it's not usual in normal writing, and the underlying reason should provide a clue as to better ways of handling the issue. Second, brilliant you are validating - and I encourage you to keep doing so - but it is possible to treat validation as a guide, and if step #1 doesn;t provide clues, you ight decide to ignore the error once you have checked word-wrap won't cause other problems.

... it caused the #mainContent to lay over the navbar so I inserted (position: relative; z-index: 1 in the #navbar and that threw the navbar over the #mainContent (I think) and the navbar is fully functinal again.

Ok, the margin code was margin:0 200px; - shorthand for margin: top/bottom right/left
Best way to deal with an element that is behaving badly is to resolve the undesired behaviour of that element. Only adjust the surrounding elements if that doesn't work. So, although adjusting the navbar was a good application of stacking theory - and has worked, I'd suggest that rather than adding more code to change the behaviour of another element, just adjust the margins on #mainContent so it is no longer overlaying the navbar. Something like
margin: 30px 200px 0; - top, left/right, bottom (Adjust to suit)
I also suspect the "overlay" may be caused by setting #mainContent position:relative. Unless required, remove that as well (may require adjusting the margins again).

I have played with floats and clears in the #container because that resolved someone else's problem (I was perusing similar problems in the forum) and that does not appear to be working for me or I have not figured out the right combination. I
Great learning exercise, but I'd strong suggest avoiding anything that combines positioning and floats ... and clears ... for what looks like a simple margin trouble. When first starting it is tempting to deal with a code problem by adding more code. Trouble is, the more code, the more things can "break" :) Code as little as possible!
Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved