Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferent colours for different articles using a:hover
    primarykey
    data
    text
    <p>I'm trying to assign three different colours to three different articles on a single page using <code>a:hover</code> in Wordpress. </p> <p>This is the site <del><a href="http://paragrams.wpshower.com/" rel="nofollow noreferrer">http://paragrams.wpshower.com/</a></del></p> <p>At present all the articles turn pale yellow on <code>a:hover</code>. I'm trying to create different colours for each article (for example, first article to be yellow, the second article red, third blue and so on).</p> <p>Below is the php &amp; CSS for the <code>a:hover</code> at present. I assume I need to wrap each thumb id in a different div and specify the colour in the CSS? </p> <p>PHP:</p> <pre><code>&lt;ul class="mcol"&gt; &lt;?php if(have_posts()) : ?&gt;&lt;?php while(have_posts()) : the_post(); ?&gt; &lt;li class="article"&gt; &lt;?php if ( has_post_thumbnail() ) { ?&gt; &lt;?php $imgsrcparam = array( 'alt' =&gt; trim(strip_tags( $post- &gt;post_excerpt )), 'title' =&gt; trim(strip_tags( $post- &gt;post_title )), ); $thumbID = get_the_post_thumbnail( $post-&gt;ID, 'background', $imgsrcparam ); ?&gt; &lt;div&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" class="preview"&gt;&lt;?php echo "$thumbID"; ?&gt;&lt;/a&gt;&lt;/div&gt; &lt;?php } ?&gt; &lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php the_title(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt; </code></pre> <p>and CSS:</p> <pre><code>.li_container { background-attachment: scroll; background-image: url(images/main-bg.gif); background-repeat: repeat-y; background-position: left top; } .li_container .article:hover { background-color:#57bfeb; } </code></pre> <p>This is the js:</p> <pre><code> # * Splits a &lt;ul&gt;/&lt;ol&gt;-list into equal-sized columns. # * # * Requirements: # * &lt;ul&gt; # * &lt;li&gt;"ul" or "ol" element must be styled with margin&lt;/li&gt; # * &lt;/ul&gt; # * # * @see http://www.codeasily.com/jquery/multi-column-list-with-jquery # */ jQuery.fn.makeacolumnlists = function(settings){ settings = jQuery.extend({ cols: 3, // set number of columns colWidth: 0, // set width for each column or leave 0 for auto width equalHeight: 'li', // can be false, 'ul', 'ol', 'li' startN: 1 // first number on your ordered list }, settings); if(jQuery('&gt; li', this)) { this.each(function(y) { var y=jQuery('.li_container').size(), height = 0, maxHeight = 0, t = jQuery(this), classN = t.attr('class'), listsize = jQuery('&gt; li', this).size(), percol = Math.ceil(listsize/settings.cols), contW = t.width(), bl = ( isNaN(parseInt(t.css('borderLeftWidth'),10)) ? 0 : parseInt(t.css('borderLeftWidth'),10) ), br = ( isNaN(parseInt(t.css('borderRightWidth'),10)) ? 0 : parseInt(t.css('borderRightWidth'),10) ), pl = parseInt(t.css('paddingLeft'),10), pr = parseInt(t.css('paddingRight'),10), ml = parseInt(t.css('marginLeft'),10), mr = parseInt(t.css('marginRight'),10), col_Width = Math.floor((contW - (settings.cols-1)*(bl+br+pl+pr+ml+mr))/settings.cols); if (settings.colWidth) { col_Width = settings.colWidth; } var colnum=1, percol2=percol; jQuery(this).addClass('li_cont1').wrap('&lt;div id="li_container' + (++y) + '" class="li_container"&gt;&lt;/div&gt;'); for (var i=0; i&lt;=listsize; i++) { if (colnum &gt; settings.cols) colnum = 1; var eq = jQuery('&gt; li:eq('+i+')',this); eq.addClass('li_col'+colnum); colnum++; //if(i&gt;=percol2) { percol2+=percol; colnum++; } //var eq = jQuery('&gt; li:eq('+i+')',this); //eq.addClass('li_col'+ colnum); //if(jQuery(this).is('ol')){eq.attr('value', ''+(i+settings.startN))+'';} } jQuery(this).css({cssFloat:'left', width:''+col_Width+'px'}); for (colnum=2; colnum&lt;=settings.cols; colnum++) { if(jQuery(this).is('ol')) { jQuery('li.li_col'+ colnum, this).appendTo('#li_container' + y).wrapAll('&lt;ol class="li_cont'+colnum +' ' + classN + '" style="float:left; width: '+col_Width+'px;"&gt;&lt;/ol&gt;'); } else { jQuery('li.li_col'+ colnum, this).appendTo('#li_container' + y).wrapAll('&lt;ul class="li_cont'+colnum +' ' + classN + '" style="float:left; width: '+col_Width+'px;"&gt;&lt;/ul&gt;'); } } if (settings.equalHeight=='li') { for (colnum=1; colnum&lt;=settings.cols; colnum++) { jQuery('#li_container'+ y +' li').each(function() { var e = jQuery(this); var border_top = ( isNaN(parseInt(e.css('borderTopWidth'),10)) ? 0 : parseInt(e.css('borderTopWidth'),10) ); var border_bottom = ( isNaN(parseInt(e.css('borderBottomWidth'),10)) ? 0 : parseInt(e.css('borderBottomWidth'),10) ); height = e.height() + parseInt(e.css('paddingTop'), 10) + parseInt(e.css('paddingBottom'), 10) + border_top + border_bottom; maxHeight = (height &gt; maxHeight) ? height : maxHeight; }); } for (colnum=1; colnum&lt;=settings.cols; colnum++) { var eh = jQuery('#li_container'+ y +' li'); var border_top = ( isNaN(parseInt(eh.css('borderTopWidth'),10)) ? 0 : parseInt(eh.css('borderTopWidth'),10) ); var border_bottom = ( isNaN(parseInt(eh.css('borderBottomWidth'),10)) ? 0 : parseInt(eh.css('borderBottomWidth'),10) ); mh = maxHeight - (parseInt(eh.css('paddingTop'), 10) + parseInt(eh.css('paddingBottom'), 10) + border_top + border_bottom ); eh.height(mh); } } else if (settings.equalHeight=='ul' || settings.equalHeight=='ol') { for (colnum=1; colnum&lt;=settings.cols; colnum++) { jQuery('#li_container'+ y +' .li_cont'+colnum).each(function() { var e = jQuery(this); var border_top = ( isNaN(parseInt(e.css('borderTopWidth'),10)) ? 0 : parseInt(e.css('borderTopWidth'),10) ); var border_bottom = ( isNaN(parseInt(e.css('borderBottomWidth'),10)) ? 0 : parseInt(e.css('borderBottomWidth'),10) ); height = e.height() + parseInt(e.css('paddingTop'), 10) + parseInt(e.css('paddingBottom'), 10) + border_top + border_bottom; maxHeight = (height &gt; maxHeight) ? height : maxHeight; }); } for (colnum=1; colnum&lt;=settings.cols; colnum++) { var eh = jQuery('#li_container'+ y +' .li_cont'+colnum); var border_top = ( isNaN(parseInt(eh.css('borderTopWidth'),10)) ? 0 : parseInt(eh.css('borderTopWidth'),10) ); var border_bottom = ( isNaN(parseInt(eh.css('borderBottomWidth'),10)) ? 0 : parseInt(eh.css('borderBottomWidth'),10) ); mh = maxHeight - (parseInt(eh.css('paddingTop'), 10) + parseInt(eh.css('paddingBottom'), 10) + border_top + border_bottom ); /*eh.height(mh);*/ } } jQuery('#li_container' + y).append('&lt;div style="clear:both; overflow:hidden; height:0px;"&gt;&lt;/div&gt;'); }); } } jQuery.fn.uncolumnlists = function(){ jQuery('.li_cont1').each(function(i) { var onecolSize = jQuery('#li_container' + (++i) + ' .li_cont1 &gt; li').size(); if(jQuery('#li_container' + i + ' .li_cont1').is('ul')) { jQuery('#li_container' + i + ' &gt; ul &gt; li').appendTo('#li_container' + i + ' ul:first'); for (var j=1; j&lt;=onecolSize; j++) { jQuery('#li_container' + i + ' ul:first li').removeAttr('class').removeAttr('style'); } jQuery('#li_container' + i + ' ul:first').removeAttr('style').removeClass('li_cont1').insertBefore('#li_container' + i); } else { jQuery('#li_container' + i + ' &gt; ol &gt; li').appendTo('#li_container' + i + ' ol:first'); for (var j=1; j&lt;=onecolSize; j++) { jQuery('#li_container' + i + ' ol:first li').removeAttr('class').removeAttr('style'); } jQuery('#li_container' + i + ' ol:first').removeAttr('style').removeClass('li_cont1').insertBefore('#li_container' + i); } jQuery('#li_container' + i).remove(); }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload