{"id":45959,"date":"2022-11-06T01:28:15","date_gmt":"2022-11-06T01:28:15","guid":{"rendered":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/?p=45959"},"modified":"2026-10-11T05:16:33","modified_gmt":"2026-10-11T05:16:33","slug":"wordpress-admin-top-horizontal-menu","status":"publish","type":"post","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wordpress-admin-top-horizontal-menu\/","title":{"rendered":"WordPress Admin Menu as a Top Horizontal Bar"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The WordPress admin menu is a tall sidebar on the left. On a wide screen that is fine, but on a laptop it takes 160px of every screen, and with a long list of plugin menus you scroll the sidebar to reach Settings. This CSS moves the WordPress admin menu to a horizontal bar at the top, with the submenus as dropdowns.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is CSS only, so nothing in WordPress changes: the same menu items, the same order, the same permissions. The collapsed (folded) menu becomes a smaller icon bar. Below 782px WordPress keeps its own mobile menu.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The CSS<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"css\" class=\"language-css\">\/* Horizontal wp-admin menu (dpc). Desktop only; below 782px WordPress keeps its mobile menu. *\/\n@media (min-width: 782px) {\n\t#wpcontent,\n\t#wpfooter {\n\t\tmargin-left: 0 !important;\n\t\tmargin-right: 0 !important;\n\t}\n\n\t\/* Room for the menu bar above the content. *\/\n\t.wp-admin #wpbody-content {\n\t\tmargin-top: 80px;\n\t}\n\n\t.wp-admin.folded #wpbody-content {\n\t\tmargin-top: 50px;\n\t}\n\n\t#adminmenu,\n\t#adminmenuback,\n\t#adminmenuwrap {\n\t\twidth: 100% !important;\n\t\tmargin: 0;\n\t}\n\n\t#adminmenuwrap,\n\t#adminmenuback {\n\t\tposition: fixed !important;\n\t\tbottom: auto;\n\t\tbox-shadow: 0 2px 2px rgba(0, 0, 0, 0.05), 0 0 1px rgba(0, 0, 0, 0.15);\n\t}\n\n\t#adminmenu {\n\t\tdisplay: flex;\n\t}\n\n\t#adminmenu &gt; li {\n\t\tdisplay: block;\n\t}\n\n\t#adminmenu &gt; li::after,\n\t#adminmenu &gt; li &gt; a::after {\n\t\tdisplay: none !important;\n\t}\n\n\t#adminmenu a.menu-top {\n\t\tpadding: 10px 4px;\n\t\topacity: 0.5;\n\t\ttransition: opacity 0.2s ease-in, box-shadow 0.3s ease-in;\n\t}\n\n\t.folded #adminmenu a.menu-top {\n\t\tpadding: 5px 0;\n\t}\n\n\t#adminmenu a.wp-has-current-submenu,\n\t#adminmenu a.current,\n\t#adminmenu li.current a,\n\t#adminmenu a.menu-top:hover,\n\t#adminmenu a.menu-top:focus {\n\t\topacity: 1;\n\t}\n\n\t#adminmenu a.menu-top:hover,\n\t#adminmenu a.menu-top:focus {\n\t\tbox-shadow: inset 0 -5px 0 0 currentColor;\n\t}\n\n\t#adminmenu div.wp-menu-image {\n\t\tdisplay: flex;\n\t\twidth: 100%;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\t\tfloat: none;\n\t\tpadding: 0;\n\t}\n\n\t#adminmenu div.wp-menu-name {\n\t\tpadding: 8px;\n\t\tfont-size: 10px;\n\t\ttext-align: center;\n\t}\n\n\t\/* Submenus open as dropdowns on hover and on keyboard focus. *\/\n\t#adminmenu .wp-submenu {\n\t\tposition: absolute !important;\n\t\ttop: -1000em !important;\n\t\tmargin-top: 0 !important;\n\t\tbox-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);\n\t}\n\n\t#adminmenu li:hover .wp-submenu,\n\t#adminmenu li:focus-within .wp-submenu {\n\t\ttop: 100% !important;\n\t\tleft: 0 !important;\n\t}\n\n\t#adminmenu #collapse-menu {\n\t\tmargin: auto 0;\n\t}\n\n\t#adminmenu #collapse-menu .collapse-button-label {\n\t\tdisplay: none;\n\t}\n\n\t\/* The WooCommerce admin header is fixed to the left of the old sidebar and would cover the menu. *\/\n\t.woocommerce-layout__header,\n\t.woocommerce-layout__activity-panel-wrapper {\n\t\tdisplay: none;\n\t}\n\n\t.woocommerce-page #wpbody-content,\n\t.woocommerce-page #wpbody {\n\t\tmargin-top: 0 !important;\n\t}\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Add it with Scripts Organizer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/dplugins.com\/downloads\/scripts-organizer\/\">Scripts Organizer<\/a> go to <strong>Code Blocks \u2192 Add New<\/strong> and give the block a name. Set <strong>Trigger location<\/strong> to <strong>Admin only<\/strong>, tick <strong>Header<\/strong> under <strong>Script location<\/strong>, set <strong>Header Mode<\/strong> to <strong>CSS<\/strong>, paste the CSS and publish.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With <strong>Admin only<\/strong> Scripts Organizer prints the CSS in the <code>&lt;head&gt;<\/code> of every wp-admin page and never on the front end. No PHP is needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How it works<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>#adminmenuwrap<\/code> and <code>#adminmenuback<\/code> keep their <code>position: fixed<\/code>, but get the full width and no bottom, so the dark sidebar becomes a bar along the top of the screen.<\/li>\n\n\n<li><code>#adminmenu<\/code> becomes a flex row. The icon sits above a small 10px label, and the inactive items are dimmed to 50% so the current section stands out.<\/li>\n\n\n<li>The content area loses its left margin and gets a top margin of 80px (50px when folded), the height of the bar.<\/li>\n\n\n<li>Submenus are moved off screen and shown under their item on <code>:hover<\/code> and on <code>:focus-within<\/code>, so they also open when you tab through the menu with the keyboard.<\/li>\n\n\n<li>The WooCommerce admin header is fixed next to the old sidebar and would cover the new bar, so it is hidden on WooCommerce screens.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Customise it<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Bigger labels: raise <code>font-size<\/code> on <code>#adminmenu div.wp-menu-name<\/code>, and raise the <code>margin-top<\/code> of <code>#wpbody-content<\/code> by the same amount so content does not slide under the bar.<\/li>\n\n\n<li>No dimming: delete <code>opacity: 0.5;<\/code> from <code>#adminmenu a.menu-top<\/code>.<\/li>\n\n\n<li>Colours come from the user&#8217;s admin colour scheme. To change them, see <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/color-admin-menu-items\/\">Color Admin Menu Items<\/a>.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Gotchas<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>With many plugin menus the bar can be wider than the screen. The extra items then sit off the right edge; fold the menu or hide menus you don&#8217;t use.<\/li>\n\n\n<li>Hiding the WooCommerce header also hides its activity panel (inbox, orders, stock). Its pages still work; delete the last two rules if you need the panel.<\/li>\n\n\n<li>The CSS overrides core admin styles with <code>!important<\/code>. A future WordPress release that changes the menu markup can break the layout, so check it after major updates.<\/li>\n\n\n<li>Plugins that add their own fixed sidebars or top bars in wp-admin can overlap the menu bar.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The older version of this post had the same layout; this version adds keyboard access to submenus and replaces the <code>rgb(0 0 0 \/ 20%)<\/code> shorthand with a plain <code>rgba()<\/code> value.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Move the WordPress admin menu from the left sidebar to a horizontal bar at the top with CSS only, with dropdown submenus and keyboard access.<\/p>\n","protected":false},"author":33,"featured_media":46901,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"WordPress Admin Menu as a Top Horizontal Bar - Code DPlugins","description":"Move the WordPress admin menu from the left sidebar to a horizontal bar at the top with CSS only, with dropdown submenus and keyboard access."},"_slim_seo_primary_term_category":0,"_slim_seo_primary_term_post_tag":0,"footnotes":""},"categories":[22,3],"tags":[],"dpc_library":[204],"class_list":["post-45959","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css","category-wordpress"],"_links":{"self":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/45959","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/comments?post=45959"}],"version-history":[{"count":1,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/45959\/revisions"}],"predecessor-version":[{"id":46871,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/45959\/revisions\/46871"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media\/46901"}],"wp:attachment":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media?parent=45959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/categories?post=45959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/tags?post=45959"},{"taxonomy":"dpc_library","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/dpc_library?post=45959"}],"curies":[{"name":"wp","href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}