简体   繁体   中英

Image rollover in a float grid style

I made a simple roll over for links in a widget area (un-sure how to do that part, not important at the moment) The site I am making this for is at www.avuedesigns.com/new Currently on the left side under the banner content box, I would like this to be that in that area.

This is what I came up with http://jsfiddle.net/paDmg/368/

So my question would be, would this work in that area(execution wise), or try a different way?.

Also would this be easy to make this a widget for wordpress to put that in that area? Our php guy is on vacation for 2 weeks, and trying to complete the project on my own. I am sure I can figure it out, I just need to be pointed in direction to a method.

Once again here is the roll over : http://jsfiddle.net/paDmg/368/

Also copy pasted here.

CSS

ul#hover-grid {
 padding: 0;
 list-style: none;
 margin: 0px auto 0;
 margin-top: 0;
 width: 220px;  
 }

#hover-grid li {
 float: left;
 padding: 2;
 margin: 0 1px 1px 1px;
 } 

#hover-grid .indiv-cell {
 width: 65px;
 height: 65px;
}

Html

 <ul id="hover-grid">


<li class="indiv-cell"><a href="#"><img data-replacementimg="http://avuedesigns.com/new/wp-content/uploads/2012/09/1.jpg" src="http://avuedesigns.com/new/wp-content/uploads/2012/09/6.jpg"></a></li>

 <li class="indiv-cell"><a href="#"><img data-replacementimg="http://avuedesigns.com/new/wp-content/uploads/2012/09/2.jpg" src="http://avuedesigns.com/new/wp-content/uploads/2012/09/6.jpg"></a></li>

 <li class="indiv-cell"><a href="#"><img data-replacementimg="http://avuedesigns.com/new/wp-content/uploads/2012/09/3.jpg" src="http://avuedesigns.com/new/wp-content/uploads/2012/09/6.jpg"></a></li>

 <li class="indiv-cell"><a href="#"><img data-  replacementimg="http://avuedesigns.com/new/wp-content/uploads/2012/09/4.jpg" src="http://avuedesigns.com/new/wp-content/uploads/2012/09/6.jpg"></a></li>

 <li class="indiv-cell"><a href="#"><img data-replacementimg="http://avuedesigns.com/new/wp-content/uploads/2012/09/1.jpg" src="http://avuedesigns.com/new/wp-content/uploads/2012/09/6.jpg"></a></li>

 <li class="indiv-cell"><a href="#"><img data-replacementimg="http://avuedesigns.com/new/wp-content/uploads/2012/09/2.jpg" src="http://avuedesigns.com/new/wp-content/uploads/2012/09/6.jpg"></a></li>


            </ul>​

Javascript

$('#hover-grid .indiv-cell').hover(function() {

//set variables to current cell attributes
var cellHeader = $(this).attr('data-hoverheader');
var cellText = $(this).attr('data-hovertext');
var replacementImg = $(this).find('a img').attr('data-replacementimg');
var oringinalImg = $(this).find('a img').attr('src');

//save original image to data variable
$(this).data('origImg', oringinalImg);



//add remove classes
$('#hover-grid .indiv-cell').removeClass('newClass');
$(this).addClass('newClass', 1000);
$(this).find('a img').hide().attr('src', replacementImg).fadeIn(300);
$('.master-cell h1').hide().text(cellHeader).fadeIn(300);
$('.master-cell p').hide().text(cellText).fadeIn(300);


//return false;
}, function() {
$(this).find('a img').hide().attr('src', $(this).data('origImg')).fadeIn(10);
});​

I believe you want to turn your html into a dynamic nav menu, right? The Wordpress codex has settings for this where you can structure the menu to match your html .

I think some settings like this might get you started

<?php $defaults = array(
'theme_location'  => 'custom-menu',
'container'       => 'div', 
'menu_class'      => 'indiv-cell', 
'echo'            => true,
'fallback_cb'     => 'wp_page_menu',
'items_wrap'      => '<ul id="hover-grid">%2$s</ul>',
); ?>

<?php wp_nav_menu( $defaults ); ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM