{"id":2037,"date":"2014-01-28T21:23:00","date_gmt":"2014-01-28T21:23:00","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=2037"},"modified":"2014-01-28T21:35:36","modified_gmt":"2014-01-28T21:35:36","slug":"creating-navicon-icon","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/creating-navicon-icon\/","title":{"rendered":"Creating the Navicon without an icon"},"content":{"rendered":"<p>I&#8217;m a big fan creating &#8220;graphic-free websites&#8221;. My ultimate, yet somewhat lame goal in life is to create an entire website without using a single image file. I&#8217;m progressing towards that goal and CSS is helping me every step of the way.<\/p>\n<p>One tip that I&#8217;ve discovered towards that goal is the creation of an image-free <a href=\"https:\/\/www.google.com\/search?q=navicon&amp;safe=off&amp;rlz=1C1LENP_enUS474US474&amp;espv=210&amp;es_sm=93&amp;tbm=isch&amp;tbo=u&amp;source=univ&amp;sa=X&amp;ei=ohzoUuClEPHmsATtu4CQCA&amp;ved=0CFEQsAQ&amp;biw=1481&amp;bih=794\" target=\"_blank\">navicon<\/a>. Navicons are becoming a universally recognizable substitution for complete navigation bars. However, if you are using an image for your navicon, you are essentially replacing a text-based navigation element with an element that requires another HTTP connection (an image), hence slowing down your page load.<\/p>\n<p>The good news is that you can, and many have, created navicons without the use of images. There are two tricks that I like to use. I typically favor the first one as it is a little bit safer than relying on unicode characters.<\/p>\n<h3>The three-hyphen navicon<\/h3>\n<p>Believe it or not, I&#8217;ve actually created a much nicer looking navicon by rotating the lowercase letter &#8220;L&#8221; 90 degrees and placing three of them next to each other. But, we leaving IE 8 hanging as it doesn&#8217;t support CSS 3 transformations.<\/p>\n<p>So, I typically settle on using three hyphens, with reduced line spacing to create the navicon effect. The CSS follows:<\/p>\n<pre class=\"prettyprint\"><code>header ul:before { \r\n    content: '-\\A-\\A-'; \r\n    float: left; \r\n    width: 16px; \r\n    height: 16px; \r\n    font-size: 2rem; \r\n    color: #e7e7e7; \r\n    line-height: 3px;\r\n    white-space: pre; \r\n    border: 1px solid #e7e7e7; \r\n    text-align: center; \r\n}\r\nheader ul:hover:before { \r\n    color: #fff; \r\n    border-color: #fff; \r\n}\r\n@media screen and (-webkit-min-device-pixel-ratio:0) { \r\n    header ul:before { height: 15px; padding-top: 1px; } \r\n}<\/code><\/pre>\n<p>This will not work in IE7 (as IE 7 does not support the :before pseudoselector). It also requires a slight adjustment for webkit-based browsers, hence the -webkit-min-device-pixel-ratio media query seen at the end.<\/p>\n<h3>Creating the navicon with a unicode character<\/h3>\n<p>After a few trips around the block with the CSS method, I started to wonder if there was a similar unicode character that might equally represent a navicon. I remembered back to one of my college math classes that there existed a symbol with three parallel lines. I completely forgot what it means, but after a quick Google, I came to the mathematical symbol for &#8220;Identical To&#8221;.<\/p>\n<p>The Identical To character can be found as <a href=\"http:\/\/www.unicodemap.org\/details\/0x2261\/index.html\" target=\"_blank\">unicode character 0x2261<\/a>: \u2261<\/p>\n<p>This is certainly a much simpler approach than using CSS, but I haven&#8217;t fully tested against all fonts, browsers and operating systems.<\/p>\n<p>I imagine there are numerous other methods to build the navicon with HTML &amp; CSS alone, so drop a comment if you have any other creative ideas!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The navicon is almost universally recognizable as a hover-for-navigation element, but it requires another image be loaded, unless you are clever about implementing it.<\/p>\n","protected":false},"author":1,"featured_media":2121,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[12],"tags":[151,128],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/2037"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=2037"}],"version-history":[{"count":11,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/2037\/revisions"}],"predecessor-version":[{"id":2126,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/2037\/revisions\/2126"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media\/2121"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=2037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=2037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=2037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}