www.webdeveloper.com
Results 1 to 2 of 2

Thread: Image Rollover

  1. #1
    Join Date
    Jul 2006
    Posts
    77

    Image Rollover

    I'm trying to figure out the positioning to do a image roller but after a hour I can't get it.

    For some reason it's only detcting the "portfolio" link.

    HTML:
    Code:
    <body>
    
    	<div id="navigation">
    
    		<ul id="navmenu">
    				<li id="home"><a href="index.html" title="Home"></a></li>
    				<li id="services"><a href="services.html" title="Services"></a></li>               
    				<li id="portfolio"><a href="portfolio.html" title="Portfolio"></a></li>
    		</ul>
    
    	</div>
    </body>
    CSS:
    Code:
    @charset "utf-8";
    /* CSS Document */
    
    a:link {
    	color:#CC0000;
    	font-weight:bold;
    	text-decoration:none;
    }
    
    a:hover {
    	text-decoration:underline;
    }
    a:visited {
    	color:#CC0000;
    	font-weight:normal;
    	text-decoration:none;
    }
    
    div#navigation {
    	margin: 4px;
    
    }
    ul#navmenu {
    	width:125px;
    	height:125px;
    	margin:0;
    	padding:0;
    	background:url(menu.jpg) no-repeat;
    	position:relative;
    }
    #navmenu li {
    	margin: 0; 
    	padding: 0; 
    	list-style: none;
    	position: absolute;
    	top: 0;
    }
    #navmenu li,#navmenu a {
    	height: 125px; 
    	display: block;
    }
    img {
    	border:none;
    }
    #navmenu a{
    	text-decoration:none;
    }
    #navmenu a i { 
    	visibility: hidden;
    }
    
    #home {top: 0; width: 125px; height:43px;}
    #services {top:-43px; width: 125px; height:43px;}
    #portfolio {top: -86px; width: 125px; height:43px;}
    
    
    #home a:hover,#home a:active {
    	background:transparent url(menu.jpg)  900px -113px no-repeat;
    }
    #services a:hover,#services a:active {
    	background:url(menu.jpg) -131px 0px no-repeat;
    }
    #portfolio a:hover,#portfolio a:active {
    	background:url(menu.jpg) -131px 0 no-repeat;
    }
    Thanks in advance
    Attached Images Attached Images
    Last edited by mikegreenia.com; 07-10-2008 at 07:47 PM.

  2. #2
    Join Date
    Mar 2006
    Location
    Newcastle NSW Australia
    Posts
    4,033
    The background image should be applied to the <a> elements, and the <a>s sized to only show one. If the id's are moved to the <a> tags :
    Code:
    	<div id="navigation">
    
    		<ul id="navmenu">
    				<li><a href="index.html" title="Home" id="home"></a></li>
    				<li><a href="services.html" title="Services" id="services"></a></li>               
    				<li><a href="portfolio.html" title="Portfolio" id="portfolio"></a></li>
    		</ul>
    
    	</div>
    Then the css can be :
    Code:
    ul#navmenu {
    	width:126px;
    	height:125px;
    	margin:0;
    	padding:0;
    }
    #navmenu li {
    	margin: 0 0 7px; 
    	padding: 0; 
    	list-style: none;
    }
    #navmenu a {
    	height: 37px; 
    	display: block;
    }
    img {
    	border:none;
    }
    #navmenu a{
    	text-decoration:none;
    	background-image: url(menu.jpg);
    	background-repeat: no-repeat;
    }
    #home {
    	background-position: left top;
    }
    #services {
    	background-position: left center;
    }
    #portfolio {
    	background-position: left bottom;
    }
    #home:hover, #home:active {
    	background-position: -131px top;
    }
    #services:hover, #services:active {
    	background-position: -131px center;
    }
    #portfolio:hover, #portfolio:active {
    	background-position: -131px bottom;
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles