{"id":382,"date":"2013-03-03T19:49:36","date_gmt":"2013-03-04T00:49:36","guid":{"rendered":"http:\/\/www.cfchimp.com\/wordpress\/?p=382"},"modified":"2024-12-05T11:56:30","modified_gmt":"2024-12-05T16:56:30","slug":"a-less-mixin-to-change-font-color-based-on-font-size","status":"publish","type":"post","link":"https:\/\/csimmons.dev\/blog\/2013\/03\/a-less-mixin-to-change-font-color-based-on-font-size\/","title":{"rendered":"A LESS Mixin to change font-color based on font-size"},"content":{"rendered":"<p>Just a little LESS fun for the day&#8230; Here is a LESS Mixin to change font-color based on font-size.<\/p>\n<p>Green big.<br \/>\nYellow just right.<br \/>\nRed little.<\/p>\n<p>It can be used with or without passing units (without units will use pixels).  Adds bold just for fun.<\/p>\n<p><code><br \/>\n.colorBySize(@pxValue) when (@pxValue < 12px){\n    color:red;\n}\n\n.colorBySize(@pxValue) when (@pxValue =< 16px) and (@pxValue >= 12px){<br \/>\n    color:yellow;<br \/>\n}<\/p>\n<p>.colorBySize(@pxValue) when (@pxValue > 16px){<br \/>\n    color:green;<br \/>\n}<\/p>\n<p>.colorBySize(@_) when not (ispixels(@_)){<br \/>\n    font-size: ~\"@{_}px\";<br \/>\n    \/\/ font-size: @_;<br \/>\n    font-weight: bold;<br \/>\n}<\/p>\n<p>.colorBySize(@_) when (ispixels(@_)){<br \/>\n    font-size: @_;<br \/>\n    font-weight: bold;<br \/>\n}<\/p>\n<p>p.little{<br \/>\n    .colorBySize(9);<br \/>\n}<\/p>\n<p>p.justright{<br \/>\n    .colorBySize(12);<br \/>\n}<\/p>\n<p>p.big{<br \/>\n    .colorBySize(18);<br \/>\n}<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just a little LESS fun for the day&#8230; Here is a LESS Mixin to change font-color based on font-size. Green big. Yellow just right. Red little. It can be used with or without passing units (without units will use pixels). Adds bold just for fun. .colorBySize(@pxValue) when (@pxValue < 12px){ color:red; } .colorBySize(@pxValue) when (@pxValue ... <a title=\"A LESS Mixin to change font-color based on font-size\" class=\"read-more\" href=\"https:\/\/csimmons.dev\/blog\/2013\/03\/a-less-mixin-to-change-font-color-based-on-font-size\/\" aria-label=\"Read more about A LESS Mixin to change font-color based on font-size\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_cloudinary_featured_overwrite":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[68],"tags":[40,37],"class_list":["post-382","post","type-post","status-publish","format-standard","hentry","category-developer","tag-css","tag-less"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pbVg43-6a","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/comments?post=382"}],"version-history":[{"count":0,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/382\/revisions"}],"wp:attachment":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/media?parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/categories?post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/tags?post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}