{"id":3307,"date":"2021-07-26T15:56:19","date_gmt":"2021-07-26T18:56:19","guid":{"rendered":"https:\/\/danillolima.com\/en\/?p=3307"},"modified":"2021-07-26T15:56:19","modified_gmt":"2021-07-26T18:56:19","slug":"correcting-the-positioning-of-mega-menu-in-oxygen-builder","status":"publish","type":"post","link":"https:\/\/danillolima.com\/en\/wordpress\/correcting-the-positioning-of-mega-menu-in-oxygen-builder\/","title":{"rendered":"Correcting the positioning of Mega Menu in Oxygen Builder"},"content":{"rendered":"\n<p>When using the component Mega Menu from the Composite Elements in a sticky header or when logged on WordPress the component Mega Menu compute the top offset of the menu (.oxel_megamenu__wrapper) in a wrong way. <\/p>\n\n\n\n<p>Logged in WordPress the navbar is computed making the element stay with a top offset plus the height of the WordPress navbar.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/danillolima.com\/en\/wp-content\/uploads\/sites\/2\/2021\/07\/image-1024x267.png\" alt=\"\" class=\"wp-image-3312\" width=\"840\" height=\"219\" title=\"\" srcset=\"https:\/\/danillolima.com\/en\/wp-content\/uploads\/sites\/2\/2021\/07\/image-1024x267.png 1024w, https:\/\/danillolima.com\/en\/wp-content\/uploads\/sites\/2\/2021\/07\/image-300x78.png 300w, https:\/\/danillolima.com\/en\/wp-content\/uploads\/sites\/2\/2021\/07\/image-768x201.png 768w, https:\/\/danillolima.com\/en\/wp-content\/uploads\/sites\/2\/2021\/07\/image.png 1072w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><figcaption class=\"wp-element-caption\">Top margin of menu when logged<\/figcaption><\/figure>\n\n\n\n<p>You just need change the Mega Menu Code from this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var bottom = jQuery(this).offset().top + jQuery(this).outerHeight(true);<\/code><\/pre>\n\n\n\n<p>To this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var bottom = jQuery(this).position().top + jQuery(this).outerHeight(true);<\/code><\/pre>\n\n\n\n<p>This way the browser will compute the top offset from the Mega Menu Links div and not from document.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When using the component Mega Menu from the Composite Elements in a sticky header or when logged on WordPress the component Mega Menu compute the top offset of the menu (.oxel_megamenu__wrapper) in a wrong way. Logged in WordPress the navbar is computed making the element stay with a top offset plus the height of the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[42],"tags":[],"class_list":["post-3307","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/posts\/3307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/comments?post=3307"}],"version-history":[{"count":0,"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/posts\/3307\/revisions"}],"wp:attachment":[{"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/media?parent=3307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/categories?post=3307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danillolima.com\/en\/wp-json\/wp\/v2\/tags?post=3307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}