{"id":1725,"date":"2015-05-13T17:10:32","date_gmt":"2015-05-13T17:10:32","guid":{"rendered":"http:\/\/cssreset.com\/?p=1725"},"modified":"2015-05-13T17:10:32","modified_gmt":"2015-05-13T17:10:32","slug":"creating-a-fixed-menu-to-the-left-or-right-of-browser","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/creating-a-fixed-menu-to-the-left-or-right-of-browser\/","title":{"rendered":"Creating a Fixed Menu to the Left or Right of Browser"},"content":{"rendered":"<p>There are a number of reasons why you may need to fix your menu to a users browser and this tutorial will help you understand how to do it with CSS.<\/p>\n<p>Most menus are fixed to the top or the bottom of a browser, but this tutorial is going to address fixing a menu to the right or left of a user screen.  You will still have full control over the top, bottom or middle of the browser, but it will be mainly focused on one side.  <\/p>\n<p>It&#8217;s worth noting that if you are concerned with being mobile responsive, that you do not use fixed positioning, unless you change it with <a href=\"http:\/\/www.cssnewbie.com\/embedding-video-responsive-site\/\">an @media inquiry<\/a>. <\/p>\n<p>So we begin the tutorial with a basic layout:<\/p>\n<pre class=\"prettyprint linenums\">&lt;head&gt;\r\n&lt;style type=\"text\/css\"&gt;\r\nbody{\r\n    margin:0px;\r\n    background:#000;\r\n}\r\n.header {\r\n    height:30px;\r\n    background:#DDDDDD;\r\n    width:960px;\r\n    margin:0px auto;\r\n}\r\n.content {\r\n    width:960px;\r\n    background: #F0F0F0;\r\n    border: 1px solid #CCC;\r\n    margin: 20px auto;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div class=\"menu\"&gt;&lt;ul&gt;&lt;li&gt;Menu Item #1&lt;\/li&gt;&lt;li&gt;Menu Item #2&lt;\/li&gt;&lt;li&gt;Menu Item #3&lt;\/li&gt;&lt;\/ul&gt; &lt;\/div&gt;\r\n    &lt;div&gt;&lt;\/div&gt;\r\n\r\n    &lt;div&gt;&lt;\/div&gt;<\/pre>\n<p>Of course the menu items will actually be links, but for our purposes we are just focused on the positioning of the menu. <\/p>\n<p>So because the menu will be fixed to the browser, it doesn&#8217;t really matter where the menu code is situated.  The only consideration is if you are also integrating a mobile strategy.  If you are, then placement of the menu code should revert back to where it is in the layout.  Or, you could change the fixed position to <a href=\"\/creating-fixed-headers-with-css\/\">the top or bottom of the screen<\/a>, which may help in the mobile space. <\/p>\n<p>The CSS property to focus on here is <code>position: fixed;<\/code>, but there are other additional properties to consider including orientation:<\/p>\n<p><code>top: 0;<\/code><br \/>\n<code>bottom: 0;<\/code><br \/>\n<code>left: 0;<\/code><br \/>\n<code>right: 0;<\/code><\/p>\n<p>So let&#8217;s put it all together and say for example, you want to fix your menu to the top right of the browser.  Then it would look something like:<\/p>\n<p><code><br \/>\n.menu {<br \/>\nposition: fixed;<br \/>\ntop: 0;<br \/>\nright: 0;<br \/>\n<\/code><\/p>\n<p>That orients the menu fixed to the top right of the screen.  Likewise, you can make adjustments to it by adding pixels to the placement too, like <code>top: 10px;<\/code>.<\/p>\n<p>Once you have the menu fixed to a portion of the screen, then you can play with vertical vs. horizontal menus, <a href=\"http:\/\/css3files.com\/background\/\">background colors<\/a>, and more. <\/p>\n<p>We hope you have enjoyed the tutorial and encourage you to send in requests for future tutorial topics. And before you hurry off, check out our partner site to <a href=\"http:\/\/www.learningjquery.com\/\">start learning the beginnings of jQuery<\/a>. <\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>There are a number of reasons why you may need to fix your menu to a users browser and this tutorial will help you understand how to do it with CSS.<\/p>\n<p>Most menus are fixed to the top or the bottom [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/creating-a-fixed-menu-to-the-left-or-right-of-browser\/\" title=\"Click to read 'Creating a Fixed Menu to the Left or Right of Browser'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[61,6,1],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1725"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=1725"}],"version-history":[{"count":5,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1725\/revisions"}],"predecessor-version":[{"id":1733,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1725\/revisions\/1733"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=1725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=1725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=1725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}