dylanbaumannn
02-03-2012, 04:21 PM
Hello All! (it's my first post! :) )
The Problem
I'm currently working on a website for a client and I've run into an issue that's really got me scratching my head.
When viewing the site in Chrome or Safari the navigation, which is just a UL with some LI's floated left inside of it, displays perfectly. However, when the site is viewed in Firefox the width of the last LI (controlled by some java to remove some styling) is calculated differently and causes it to become too long to fit inside of the UL.
I've done some research about how firefox applies widths to different elements, however I was unable to find anything that I could apply to my own problem.
The HTML
<div id="navigation">
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Resources</a></li>
<li><a href="#">Community Outreach</a></li>
<li><a href="#">D.A.R.E.</a></li>
<li><a href="#">Recruitment</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Crimestoppers</a></li>
</ul>
</div> <!-- /navigation -->
The CSS
#navigation {
float:left;
width:900px;
height:70px;
background:url(../images/navgradient.png) #004f74;
border-radius:8px 8px 0 0;
}
#navigation ul{
width:900px;
}
/* 1/3 on the border */
#navigation ul li:after{
content:'';
height:70px;
position:absolute;
margin-top:-70px;
margin-left:-21px;
border-left:1px solid #216585;
}
/* 2/3 on the border */
#navigation ul li:before{
content:'';
height:70px;
position:absolute;
margin-left:-20px;
border-left:1px solid #000000;
}
/* 3/3 on the border */
/* Styling of the Navigation items */
#navigation ul li{
padding:0 19px 0 18px;
margin:0 2px 0 0;
float:left;
border-left:1px solid #216585;
}
/* removes borders from first nav */
#navigation ul li:first-child:after, #navigation ul li:first-child:before{
border:none;
}
#navigation ul li:last-child:after{
margin-left:-24px;
}
#navigation ul li:last-child:before{
margin-left:-23px;
}
The Java
$(function() {
// removes styling of the last item in the list
$('#navigation ul li:last').css("padding","0 21px 0 21px");
$('#navigation ul li:last').css("border-left","1px solid #216585");
$('#navigation ul li:last').css("background","none");
$('#navigation ul li:last').css("border-radius","0 8px 0 0");
$('#navigation ul li:last').css("margin","0");
$('#navigation ul li:last:before').css("margin-left","0");
$('#navigation ul li:last:after').css("margin-left","0");
});
The Problem
I'm currently working on a website for a client and I've run into an issue that's really got me scratching my head.
When viewing the site in Chrome or Safari the navigation, which is just a UL with some LI's floated left inside of it, displays perfectly. However, when the site is viewed in Firefox the width of the last LI (controlled by some java to remove some styling) is calculated differently and causes it to become too long to fit inside of the UL.
I've done some research about how firefox applies widths to different elements, however I was unable to find anything that I could apply to my own problem.
The HTML
<div id="navigation">
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Resources</a></li>
<li><a href="#">Community Outreach</a></li>
<li><a href="#">D.A.R.E.</a></li>
<li><a href="#">Recruitment</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Crimestoppers</a></li>
</ul>
</div> <!-- /navigation -->
The CSS
#navigation {
float:left;
width:900px;
height:70px;
background:url(../images/navgradient.png) #004f74;
border-radius:8px 8px 0 0;
}
#navigation ul{
width:900px;
}
/* 1/3 on the border */
#navigation ul li:after{
content:'';
height:70px;
position:absolute;
margin-top:-70px;
margin-left:-21px;
border-left:1px solid #216585;
}
/* 2/3 on the border */
#navigation ul li:before{
content:'';
height:70px;
position:absolute;
margin-left:-20px;
border-left:1px solid #000000;
}
/* 3/3 on the border */
/* Styling of the Navigation items */
#navigation ul li{
padding:0 19px 0 18px;
margin:0 2px 0 0;
float:left;
border-left:1px solid #216585;
}
/* removes borders from first nav */
#navigation ul li:first-child:after, #navigation ul li:first-child:before{
border:none;
}
#navigation ul li:last-child:after{
margin-left:-24px;
}
#navigation ul li:last-child:before{
margin-left:-23px;
}
The Java
$(function() {
// removes styling of the last item in the list
$('#navigation ul li:last').css("padding","0 21px 0 21px");
$('#navigation ul li:last').css("border-left","1px solid #216585");
$('#navigation ul li:last').css("background","none");
$('#navigation ul li:last').css("border-radius","0 8px 0 0");
$('#navigation ul li:last').css("margin","0");
$('#navigation ul li:last:before').css("margin-left","0");
$('#navigation ul li:last:after').css("margin-left","0");
});