Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Simplify CSS Image Sprite

Avatar of Blue Street Tech
Blue Street TechFlag for United States of America asked on
Web DevelopmentCSSHTML
5 Comments1 Solution498 ViewsLast Modified:
I was not sure if i had to do it this way or not and need expert advice.

Typically, i am use to doing sprites when each image has the same dimensions. However, each image in the nav is not the same size. So i achieved it with the code below (header HTML & CSS).

I wanted to know if i have redundancies and if there was a shorter, more concise way to do this. Thanks!
#header-nav{
	float:left; /*left*/
	margin-top:60px;
	width:705px;
}
ul#header-nav{
	margin-left:10px;		
}
ul#header-nav #nav-press{
	margin-left:20px;		
}
#header-nav li{
	display:block;
	float:left;
	margin-left:10px;
}
#header-nav li a{
	display:block;
	height:30px;
	text-indent:-9999px;
	width:85px;
}
#nav-about,
#nav-runway,
#nav-press,
#nav-social,
#nav-music,
#nav-stockist,
#nav-contact-us{
	background:url(/assets/images/nav/header-nav.gif) no-repeat 0 0;
	display:block;
	float:left;
	height:30px;
	width:85px;
}
#nav-about:hover{
	background-position:0px -30px; /*h v*/
}
#nav-runway:hover{
	background-position:-85px -30px;
}
#nav-press:hover{
	background-position:-170px -30px;
}
#nav-social:hover{
	background-position:-255px -30px;
}
#nav-music:hover{
	background-position:-340px -30px;
}
#nav-stockist:hover{
	background-position:-425px -30px;
}
#nav-contact-us:hover{
	background-position:-510px -30px;
}
#nav-about{
	background-position:0px 0px; /*h v*/
}
#nav-runway{
	background-position:-85px 0px;
}
#nav-press{
	background-position:-170px 0px;
}
#nav-social{
	background-position:-255px 0px;
}
#nav-music{
	background-position:-340px 0px;
}
#nav-stockist{
	background-position:-425px 0px;
}
#nav-contact-us{
	background-position:-510px 0px;
}
#nav-about span, 
#nav-runway span,
#nav-press span,
#nav-social span,
#nav-music span,
#nav-stockist span,
#nav-contact-us span{
	display:none;
}
<!-- Start: header-wrapper -->
<div id="header-wrapper" class="clearfix">
<!-- Start: header-logo -->
	<div id="header-logo">
		<a title="<%Page.Info%>" href="/"><img src="images/layout/site_logo.gif" alt="<%Company.Info%>" width="150" height="99" /></a>
  </div><!-- End: header-logo -->

<!-- Start: header-nav -->
	<ul id="header-nav">
    	<li id="nav-about"><a href="about-us.aspx" title="About"><span>About</span></a></li>
		<li id="nav-runway"><a href="runway.aspx" title="Runway"><span>Runway</span></a></li>
		<li id="nav-press"><a href="press.aspx" title="Press"><span>Press</span></a></li>
		<li id="nav-social"><a href="social.aspx" title="Social"><span>Social</span></a></li>
		<li id="nav-music"><a href="music.aspx" title="Music"><span>Music</span></a></li>
		<li id="nav-stockist"><a href="stockist.aspx" title="Stockist"><span>Stockist</span></a></li>
		<li id="nav-contact-us"><a href="contact-us.aspx" title="Contact Us"><span>Contact Us</span></a></li>
</ul><!-- End: header-nav -->

	<div id="header-search"><!-- Start: header-search -->
		<ss:search customtext="Search" type="custom" text="Search" />
	</div><!-- End: header-search -->

	<div id="header-cart-links"><!-- Start: header-cart-links -->
        <a href="shopping-lists.aspx">Wish List</a>  <a href="cart.aspx">Shopping Cart (<%Cart.Count%>)</a><br />
		<ss:choose>
			<ss:when condition="User.IsLoggedIn == false">
            	<a href="login.aspx" class="sign-in">Login</a>
            </ss:when>
          	<ss:otherwise>
				<a href="account.aspx">Welcome <%User.FirstName%></a> <a href="login.aspx?logout">Logout</a>
			</ss:otherwise>
		</ss:choose>
	</div><!-- End: header-cart-links -->
</div><!-- End: header-wrapper -->
ASKER CERTIFIED SOLUTION
Avatar of LZ1
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answers