{"id":360,"date":"2010-04-14T11:17:04","date_gmt":"2010-04-14T11:17:04","guid":{"rendered":"https://www.divydovy.com/?p=360"},"modified":"2020-01-23T10:30:14","modified_gmt":"2020-01-23T10:30:14","slug":"cufon-hover-fix","status":"publish","type":"post","link":"https://www.divydovy.com/2010/04/cufon-hover-fix/","title":{"rendered":"Cufon :hover Fix"},"content":{"rendered":"<p>Just a quick post. I have implemented cufon for a client&#8217;s website to replace the titles with a nice new non-web-safe font.</p>\n<p>This code worked perfectly to replace the titles with the new font.</p>\n<p><code><br />\nCufon.replace('h1', { fontFamily: 'Helvetica Neue LT W1G' });<br />\nCufon.replace('h2', { fontFamily: 'Helvetica Neue LT W1G' });<br />\nCufon.replace('h3', { fontFamily: 'Helvetica Neue LT W1G' });<br />\n</code></p>\n<p>However, the client then asked for one of the titles (which was a link within an h3) to have a hover effect to show that it was a link. Fortunately <a title=\"cufon on github\" href=\"http://wiki.github.com/sorccu/cufon/styling\">cufon now supports :hover</a>, so I was pleased to be able to implement this without resorting to separate JavaScript.</p>\n<p>However, for the life of me I couldn&#8217;t get the hover effect to work!</p>\n<p><code><br />\nCufon.replace('h1', { fontFamily: 'Helvetica Neue LT W1G' });<br />\nCufon.replace('h2', { fontFamily: 'Helvetica Neue LT W1G' });<br />\nCufon.replace('h3', { fontFamily: 'Helvetica Neue LT W1G' });<br />\nCufon('#twitter-3 .widgettitle a', {<br />\nhover: {<br />\ncolor: 'aqua'<br />\n}<br />\n});</code></p>\n<p> I had the right selector, the right syntax, everything. Finally, as a last resort, I scrapped the original code (top code excerpt to leave just the :hover replacement). Finally, it worked. So, I simply re-added the title replacement under the link :hover replacement, as below:</p>\n<p><code><br />\nCufon('#twitter-3 .widgettitle a', {<br />\nhover: {<br />\ncolor: 'aqua'<br />\n}<br />\n});<br />\nCufon.replace('h1', { fontFamily: 'Helvetica Neue LT W1G' });<br />\nCufon.replace('h2', { fontFamily: 'Helvetica Neue LT W1G' });<br />\nCufon.replace('h3', { fontFamily: 'Helvetica Neue LT W1G' });<br />\n</code></p>\n<p>Hey presto &#8211; it worked 🙂 It seems that cufon works back up your list of rules in reverse, so the h3 general replacement was overwriting the specific h3 anchor hover lines! It took me a while to work this out, so hopefully this&#8217;ll help someone else.</p>\n<p>Add a comment if you like &#8211; I&#8217;m sure the code above could be further optimised.</p>\n<h2>UPDATE</h2>\n<p>According to Rein (see comments below), cufon hover will only work on anchor (&lt;a&gt;) tags. I haven&#8217;t tested that theory myself, but worth a note here &#8211; don&#8217;t want to be the cause of lost time!</p>\n","protected":false},"excerpt":{"rendered":"<p>Just a quick post. I have implemented cufon for a client&#8217;s website to replace the titles with a nice new non-web-safe font. This code worked perfectly to replace the titles with the new font. Cufon.replace(&#8216;h1&#8217;, { fontFamily: &#8216;Helvetica Neue LT W1G&#8217; }); Cufon.replace(&#8216;h2&#8217;, { fontFamily: &#8216;Helvetica Neue LT W1G&#8217; }); Cufon.replace(&#8216;h3&#8217;, { fontFamily: &#8216;Helvetica Neue LT W1G&#8217; }); However, the client then asked for one of the titles (which was a link within an h3) to have a hover effect to show that it was a link. Fortunately cufon now supports :hover, so I was pleased to be able to [&hellip;]</p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","clkt_auto_upload":"0","_clkt_publish_and_upload":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wordproof_timestamp":false},"categories":[7],"tags":[143,142,89,145,144,125],"my_content_publications":[],"class_list":["post-360","type-post","status-publish","format-standard","hentry","category-web","tag-hover","tag-cufon","tag-resolved","tag-syntax","tag-theme","tag-wordpress"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"clkt_attachments":{"featured_image":null,"inline_attachments":[],"upload_candidates":[],"max_free_size":102400,"max_allowed_size":104857600},"_clkt_upload_mode":"new_only","clkt_content_hash":"402cf906fe82c0e26274accb52fa4875b07295466054819036bf0721245704f2","customFields":{"clkt_auto_upload":"0","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"processed_attachments":{"total_attachments":0,"uploaded_to_arweave":0,"kept_original_urls":0,"upload_summary":{"total":0,"uploaded":0,"failed":0,"too_large":0,"reused":0}}},"paymentAddress":"8_-tV4d15kVVq9Gd-Al2MAIC3LqNtJ_KgFol71TzxPw"}