{"id":30125,"date":"2017-06-05T23:01:45","date_gmt":"2017-06-05T15:01:45","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=30125"},"modified":"2025-04-04T00:01:03","modified_gmt":"2025-04-03T16:01:03","slug":"create-medium-floating-action-menu","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/","title":{"rendered":"How to Create Medium-Like Floating Action Menu"},"content":{"rendered":"<p>The popularity  of <strong>floating action menus<\/strong> has been on the rise, especially since Medium.com brought the feature into vogue. In brief, the floating action menu <strong>pops up<\/strong> when you <strong>select some text<\/strong> on a web page. The menu appears near the selection, <strong>showing different actions<\/strong> that allow you to quickly format, highlight, or share the selected text.<\/p>\n<p>In this tutorial, I\u2019ll show you how to display an <strong>action menu for a selected text snippet<\/strong> on a web page. Our action menu will enable users to <strong>tweet the selected text<\/strong> to their followers.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/create-medium-floating-action-menu\/final-demo-screenshot.jpg\" width=\"800\" height=\"515\" alt=\"Final demo\"><\/figure>\n<p class=\"recommended_top\">\n\t\t\t\t\t<strong>Read Also:<\/strong>\u00a0\n\t\t\t\t\t<a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/html5-contextual-menu\/\">Add Contextual Menu on Your Website With HTML5<\/a>\n\t\t\t\t<\/p>\n<h2>1. Create the HTML<\/h2>\n<p>The <strong>starter HTML is simple<\/strong>, we only need <strong>some text<\/strong> the user can select. For the demo, I\u2019ll use <a href=\"https:\/\/www.taleswithmorals.com\/aesop-fable-the-hart-and-the-hunter.htm\" target=\"_blank\" rel=\"noopener\">\u201cThe Hart and the Hunter\u201d<\/a> bedtime story <strong>as sample text<\/strong>.<\/p>\n<pre>\r\n&lt;article&gt;\r\n  &lt;h1&gt;The Hart and the Hunter&lt;\/h1&gt;\r\n  &lt;p&gt;The Hart was once...&lt;\/p&gt;\r\n  ...\r\n&lt;\/article&gt;\r\n<\/pre>\n<h2>2. Create the action menu template<\/h2>\n<p>I\u2019m <strong>adding the HTML code<\/strong> belonging to the action menu <strong>inside a <code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/template\" target=\"_blank\" rel=\"noopener\">&lt;template&gt;<\/a><\/code> element<\/strong>. Whatever is inside the <code>&lt;template&gt;<\/code> tag, it <strong>won\u2019t be rendered<\/strong> by browsers until it is added to the document <strong>using JavaScript<\/strong>.<\/p>\n<pre>\r\n&lt;template id=\"shareBoxTemplate\"&gt;\r\n  &lt;span id=\"shareBox\"&gt;\r\n    &lt;button&gt;&lt;\/button&gt;\r\n  &lt;\/span&gt;\r\n&lt;\/template&gt;\r\n<\/pre>\n<p><strong>Don\u2019t leave any unnecessary space<\/strong> inside the <code>&lt;template&gt;<\/code> tag, as that might disturb the action menu layout once it\u2019s inserted into the document. If you want, <strong>add more buttons<\/strong> inside <code>#shareBox<\/code> for more options.<\/p>\n<h2>3. Create the CSS<\/h2>\n<p>The CSS for the <code>#shareBox<\/code> <strong>inline container<\/strong> goes like this:<\/p>\n<pre>\r\n#shareBox {\r\n  width:    30px;\r\n  height:   30px;\r\n  position: absolute;\r\n}\r\n<\/pre>\n<p>The <code>position:absolute;<\/code> rule will let us <strong>place the menu wherever we want<\/strong> on the page.<\/p>\n<p>I also styled the <strong>action button inside <code>#shareBox<\/code><\/strong> with a background color and image and in its <code>::after<\/code> pseudo-element I <strong>added a triangle for a down arrow<\/strong>.<\/p>\n<pre>\r\n#shareBox &gt; button {\r\n  width: 100%;\r\n  height: 100%;\r\n  background-color: #292A2B;\r\n  border: none;\r\n  border-radius: 2px;\r\n  outline: none;\r\n  cursor: pointer;\r\n  background-image: url('share.png');\r\n  background-repeat: no-repeat;\r\n  background-position: center;\r\n  background-size: 70%;\r\n}\r\n#shareBox &gt; button::after {\r\n  position: absolute;\r\n  content: '';\r\n  border-top: 10px solid #292A2B;\r\n  border-left:10px solid transparent;\r\n  border-right: 10px solid transparent;\r\n  left: 5px;\r\n  top: 30px;\r\n}\r\n<\/pre>\n<h2>4. Add event handlers with JS<\/h2>\n<p>Moving on to JavaScript, we need to <strong>add event handlers<\/strong> for the <strong><code>mousedown<\/code><\/strong> and <strong><code>mouseup<\/code><\/strong> events to <strong>capture the beginning and the end<\/strong> of the text selection.<\/p>\n<p>You can also do research for <strong>other selection events<\/strong> such as <strong><code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/GlobalEventHandlers\/onselectstart\" target=\"_blank\" rel=\"noopener\">selectstart<\/a><\/code><\/strong> and use them <strong>instead of mouse events<\/strong> (which would be ideal but as of yet their browser support are not very good).<\/p>\n<p>Also <strong>add a reference<\/strong> to the <code>&lt;template&gt;<\/code> element using the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Document\/querySelector\" target=\"_blank\" rel=\"noopener\"><code>querySelector()<\/code><\/a> method.<\/p>\n<pre>\r\ndocument.addEventListener('mousedown', onMouseDown);\r\ndocument.addEventListener('mouseup', onMouseUp);\r\nvar temp = document.querySelector('#shareBoxTemplate');\r\nfunction onMouseDown() {\r\n}\r\nfunction onMouseUp() {\r\n}\r\n<\/pre>\n<h2>5. Clear previous selections<\/h2>\n<p>In the <code>mousedown<\/code> event, we\u2019ll <strong>perform some clean-up<\/strong>, i.e. clear any previous selection and the belonging action menu.<\/p>\n<pre>\r\nfunction onMouseDown() {\r\n  document.getSelection().removeAllRanges();\r\n  var shareBox = document.querySelector('#shareBox');\r\n  if (shareBox !== null)\r\n  shareBox.remove();\r\n}\r\n<\/pre>\n<p>The <strong><code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/getSelection\" target=\"_blank\" rel=\"noopener\">getSelection()<\/a><\/code><\/strong> method returns a <code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Selection\" target=\"_blank\" rel=\"noopener\">Selection<\/a><\/code> object <strong>representing the ranges of text<\/strong> currently selected by the user and the <strong><code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Selection\/removeAllRanges\" target=\"_blank\" rel=\"noopener\">removeAllRange()<\/a><\/code><\/strong> method\n<strong>removes all ranges<\/strong> from the same <code>Selection<\/code> object, thus <strong>clearing any previous selection<\/strong>.<\/p>\n<h2>6. Display the action menu<\/h2>\n<p>It is during the <code>mouseup<\/code> event, when we\u2019ll <strong>confirm if a text selection was made<\/strong> and take further action.<\/p>\n<pre>\r\nfunction onMouseUp() {\r\n  var sel = document.getSelection(),\r\n  txt = sel.toString();\r\n  if (txt !== \"\") {\r\n    var range = sel.getRangeAt(0);\r\n    if (range.startContainer.parentElement.parentElement.localName\r\n    === \"article\"\r\n    || range.startContainer.parentElement.localName\r\n    === \"article\") {\r\n        \/\/ some text in the article was selected\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p><strong>Get the selected text string<\/strong> by calling the <code><a href=\"https:\/\/developer.mozilla.org\/en\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Object\/toString\" target=\"_blank\" rel=\"noopener\">toString()<\/a><\/code> method of the <code>Selection<\/code> object. If the selected text is not empty, go ahead and <strong>get the first range<\/strong> from the <code>Selection<\/code> object.<\/p>\n<p><strong>Range<\/strong> is the <strong>selected portion<\/strong> of the document. Typically, users will make a <strong>single selection<\/strong> only, not multiple (by pressing the <span class=\"key\">ctrl<\/span>\/<span class=\"key\">cmd<\/span> key), so just get the first range object (at index 0) from the selection using <strong><code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Selection\/getRangeAt\" target=\"_blank\" rel=\"noopener\">getRangeAt(0)<\/a><\/code><\/strong>.<\/p>\n<p>Once you\u2019ve got the range, see if the selection started from a place that\u2019s <strong>inside the article<\/strong>. The <strong><code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Range\/startContainer\" target=\"_blank\" rel=\"noopener\">startContainer<\/a><\/code><\/strong> property of the range returns the DOM node <strong>from where the selection began<\/strong>.<\/p>\n<p>Sometimes (when you <strong>select within a paragraph<\/strong>), its value is just a <strong>text node<\/strong>, in which case its <strong>parent element<\/strong> will be <code>&lt;p&gt;<\/code> and the parent of the <code>&lt;p&gt;<\/code> element will be <code>&lt;article&gt;<\/code> (in the sample code in this post).<\/p>\n<p>Other times, when you select <strong>across multiple paragraphs<\/strong>, the <code>startContainer<\/code> will be <code>&lt;p&gt;<\/code> and its parent node will be <code>&lt;article&gt;<\/code>. Hence the <strong>two comparisons<\/strong> in the second <code>if<\/code> condition in the above code.<\/p>\n<p>Once the <code>if<\/code> condition passes, it\u2019s time to <strong>fetch the action menu<\/strong> from the template and add it to the document. <strong>Place the code below<\/strong> inside the second <code>if<\/code> statement.<\/p>\n<pre>\r\ndocument.body.insertBefore(document.importNode(temp.content, true), temp);\r\n<\/pre>\n<p>The <code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Document\/importNode\" target=\"_blank\" rel=\"noopener\">importNode()<\/a><\/code> method <strong>returns nodes from external documents<\/strong> (in our case, nodes from <code>&lt;template&gt;<\/code>). When it\u2019s called with the second parameter (<code>true<\/code>), the imported element\/node will <strong>come with its child elements<\/strong>.<\/p>\n<p>You can insert <code>#shareBox<\/code> <strong>anywhere in the document body<\/strong>, I\u2019ve added it before the template element.<\/p>\n<h2>7. Place the action menu<\/h2>\n<p>We want to place the action menu <strong>right above<\/strong> & <strong>at the middle of the selected area<\/strong>. To do so, <strong>get the rectangle values<\/strong> of the selected area using the <strong><code><a href=\"https:\/\/developer.mozilla.org\/en\/docs\/Web\/API\/Element\/getBoundingClientRect\" target=\"_blank\" rel=\"noopener\">getBoundingClientRect()<\/a><\/code><\/strong> method that returns the size and the position of an element.<\/p>\n<p>Then, update the <code>top<\/code> and <code>left<\/code> values of <code>#shareBox<\/code> <strong>based on the rectangle values<\/strong>. In the calculations of the new <code>top<\/code> and <code>left<\/code> values, I made use of <strong><a href=\"https:\/\/www.hongkiat.com\/blog\/ecmascript-6-template-literals\/\">ES6 template literals<\/a><\/strong>.<\/p>\n<pre>\r\nvar rect = range.getBoundingClientRect();\r\nvar shareBox = document.querySelector('#shareBox');\r\nshareBox.style.top = `calc(${rect.top}px - 38px)`;\r\nshareBox.style.left = `calc(${rect.left}px + calc(${rect.width}px \/ 2) - 30px)`;\r\n<\/pre>\n<h2>8. Add functionality<\/h2>\n<p>Now that we added the action menu near the selected text, it\u2019s time to make the selected text <strong>available for the menu options<\/strong> so that we can perform some action on it.<\/p>\n<p>Assign the selected text to a <strong>custom property of the share button<\/strong> called <code>'shareTxt'<\/code> and add a <code>mousedown<\/code> event listener to the button.<\/p>\n<pre>\r\nvar shareBtn = shareBox.querySelector('button');\r\nshareBtn['shareTxt'] = txt;\r\nshareBtn.addEventListener('mousedown', onShareClick, true);\r\n<\/pre>\n<p>The <code>true<\/code> parameter of <code>addEventListener()<\/code> <strong>prevents the <code>mousedown<\/code> event from bubbling<\/strong>.<\/p>\n<p>Inside the <code>onShareClick()<\/code> event handler, we <strong>insert the selected text into a tweet<\/strong> by accessing the <code>shareTxt<\/code> property of the button.<\/p>\n<pre>\r\nfunction onShareClick() {\r\n  window.open(`https:\/\/twitter.com\/intent\/tweet?text=${this.shareTxt}`);\r\n  this.remove();\r\n  document.getSelection().removeAllRanges()\r\n}\r\n<\/pre>\n<p>Once the <strong>button is clicked<\/strong>, it does what it\u2019s supposed to do, then remove itself from the page. It\u2019ll also <strong>clear any selection<\/strong> in the document.<\/p>\n<h2>Source code & demo<\/h2>\n<p>In the Codepen demo below, you can <strong>test<\/strong> how the action menu works. You can also find the <strong>full source code<\/strong> in our <a href=\"https:\/\/github.com\/hongkiat\/selected-text-action-menu\/\" target=\"_blank\" rel=\"noopener\">Github repo<\/a>.<\/p>\n<p><iframe height=\"416\" scrolling=\"no\" title=\"Floating Action Menu to Tweet Selected Text\" src=\"https:\/\/codepen.io\/\/hkdc\/embed\/ZKmjzg\/?height=416&theme-id=0&default-tab=result&embed-version=2\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\">See the Pen <a href=\"https:\/\/codepen.io\/\/hkdc\/pen\/ZKmjzg\/\" rel=\"nofollow\">Floating Action Menu to Tweet Selected Text<\/a> by HONGKIAT (<a href=\"https:\/\/codepen.io\/\/hkdc\" rel=\"nofollow\">@hkdc<\/a>) on <a href=\"https:\/\/codepen.io\/\" rel=\"nofollow\">CodePen<\/a>.\n<\/iframe><\/p>\n<p class=\"recommended_top\">\n\t\t\t\t\t<strong>Read Also:<\/strong>\u00a0\n\t\t\t\t\t<a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/ecmascript-6-template-literals\/\">How to Use ES6 Template Literals in JavaScript<\/a>\n\t\t\t\t<\/p>","protected":false},"excerpt":{"rendered":"<p>The popularity of floating action menus has been on the rise, especially since Medium.com brought the feature into vogue. In brief, the floating action menu pops up when you select some text on a web page. The menu appears near the selection, showing different actions that allow you to quickly format, highlight, or share the&hellip;<\/p>\n","protected":false},"author":145,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392,3395],"tags":[],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Create Medium-Like Floating Action Menu - Hongkiat<\/title>\n<meta name=\"description\" content=\"The popularity of floating action menus has been on the rise, especially since Medium.com brought the feature into vogue. In brief, the floating action\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Medium-Like Floating Action Menu\" \/>\n<meta property=\"og:description\" content=\"The popularity of floating action menus has been on the rise, especially since Medium.com brought the feature into vogue. In brief, the floating action\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-05T15:01:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-03T16:01:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/create-medium-floating-action-menu\/final-demo-screenshot.jpg\" \/>\n<meta name=\"author\" content=\"Preethi Ranjit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Preethi Ranjit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/\"},\"author\":{\"name\":\"Preethi Ranjit\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\"},\"headline\":\"How to Create Medium-Like Floating Action Menu\",\"datePublished\":\"2017-06-05T15:01:45+00:00\",\"dateModified\":\"2025-04-03T16:01:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/\"},\"wordCount\":881,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/create-medium-floating-action-menu\\\/final-demo-screenshot.jpg\",\"articleSection\":[\"Coding\",\"UI\\\/UX\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/\",\"name\":\"How to Create Medium-Like Floating Action Menu - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/create-medium-floating-action-menu\\\/final-demo-screenshot.jpg\",\"datePublished\":\"2017-06-05T15:01:45+00:00\",\"dateModified\":\"2025-04-03T16:01:03+00:00\",\"description\":\"The popularity of floating action menus has been on the rise, especially since Medium.com brought the feature into vogue. In brief, the floating action\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/create-medium-floating-action-menu\\\/final-demo-screenshot.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/create-medium-floating-action-menu\\\/final-demo-screenshot.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/create-medium-floating-action-menu\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Medium-Like Floating Action Menu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\",\"name\":\"Preethi Ranjit\",\"description\":\"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/preethi\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Create Medium-Like Floating Action Menu - Hongkiat","description":"The popularity of floating action menus has been on the rise, especially since Medium.com brought the feature into vogue. In brief, the floating action","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Medium-Like Floating Action Menu","og_description":"The popularity of floating action menus has been on the rise, especially since Medium.com brought the feature into vogue. In brief, the floating action","og_url":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2017-06-05T15:01:45+00:00","article_modified_time":"2025-04-03T16:01:03+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/create-medium-floating-action-menu\/final-demo-screenshot.jpg","type":"","width":"","height":""}],"author":"Preethi Ranjit","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Preethi Ranjit","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/"},"author":{"name":"Preethi Ranjit","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3"},"headline":"How to Create Medium-Like Floating Action Menu","datePublished":"2017-06-05T15:01:45+00:00","dateModified":"2025-04-03T16:01:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/"},"wordCount":881,"commentCount":4,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/create-medium-floating-action-menu\/final-demo-screenshot.jpg","articleSection":["Coding","UI\/UX"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/","url":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/","name":"How to Create Medium-Like Floating Action Menu - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/create-medium-floating-action-menu\/final-demo-screenshot.jpg","datePublished":"2017-06-05T15:01:45+00:00","dateModified":"2025-04-03T16:01:03+00:00","description":"The popularity of floating action menus has been on the rise, especially since Medium.com brought the feature into vogue. In brief, the floating action","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/create-medium-floating-action-menu\/final-demo-screenshot.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/create-medium-floating-action-menu\/final-demo-screenshot.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/create-medium-floating-action-menu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Medium-Like Floating Action Menu"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3","name":"Preethi Ranjit","description":"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.","url":"https:\/\/www.hongkiat.com\/blog\/author\/preethi\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-7PT","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/30125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/145"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=30125"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/30125\/revisions"}],"predecessor-version":[{"id":73478,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/30125\/revisions\/73478"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=30125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=30125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=30125"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=30125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}