{"componentChunkName":"component---src-templates-tailwindclass-js","path":"/tailwindcss/classes/tailwind-background-attachment/","result":{"data":{"site":{"siteMetadata":{"title":"Resources to help developers | Contrast | Devwares","docsLocation":""}},"mdx":{"fields":{"id":"39116aa5-c9f2-5d23-9a37-788f80b653b8","title":"Tailwind Background Attachment","slug":"/classes/tailwind-background-attachment/"},"body":"var _excluded = [\"components\"];\nfunction _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }\nfunction _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }\nfunction _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }\n/* @jsxRuntime classic */\n/* @jsx mdx */\n\nvar _frontmatter = {\n  \"lastUpdated\": \"10 May 2024\",\n  \"title\": \"Tailwind Background Attachment\",\n  \"metaTitle\": \"Tailwind Background Attachment\",\n  \"metaDescription\": \"The bg-{attachment} utility class in Tailwind CSS allows you to control the attachment behavior of background images applied to elements.\",\n  \"canonicalUrl\": \"https://windframe.dev/tailwind/classes/tailwind-background-attachment\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n    props = _objectWithoutProperties(_ref, _excluded);\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h1\", null, \"Tailwind Backgound Attachment\"), mdx(\"p\", null, \"The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"bg-{attachment}\"), \" utility class in Tailwind CSS allows you to control the attachment behavior of background images applied to elements. With Tailwind's bg-{attachment} class, you can easily adjust whether the background image scrolls with the content or stays fixed within the element.\"), mdx(\"h2\", null, \"Applying Tailwind Background Attachment\"), mdx(\"p\", null, \"To apply a specific tailwind background attachment behavior to an element, you can use the bg-{attachment} utility class, where {attachment} represents the desired background attachment. Here are the common values you can use:\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-fixed\"), \": The background image is fixed and does not scroll with the content.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-local\"), \": The background image scrolls with the content of the element.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-scroll\"), \": The background image scrolls with the content of the element, even when the element itself is scrolled.\\nHere's an example:\")), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"bg-fixed\\\"></div>\\n\")), mdx(\"h2\", null, \"Preview\"), mdx(\"div\", {\n    className: \"rounded-t-lg overflow-hidden bg-blue-100 p-10\"\n  }, mdx(\"div\", {\n    className: \"px-4\"\n  }, mdx(\"div\", {\n    className: \"max-w-lg mx-auto h-80 rounded-md overflow-y-scroll bg-cover shadow-lg bg-fixed\",\n    style: {\n      \"backgroundImage\": \"url('https://images.unsplash.com/photo-1687789903431-54cdeb56bb43?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=256&h=256&q=80')\",\n      \"backgroundPosition\": \"center -80px\"\n    }\n  }, mdx(\"div\", {\n    className: \"mt-40 bg-blue-50 p-4\"\n  }, mdx(\"div\", {\n    className: \"font-serif font-extrabold text-2xl text-blue-500 \"\n  }, \"my trip to the \"), mdx(\"p\", {\n    className: \"mt-1 font-medium text-sm text-blue-400\"\n  }, \"November 18, ...2019\"), mdx(\"p\", {\n    className: \"mt-4 text-blue-500\"\n  }, \"During my trip to the Caribbean, I had the pleasure of enjoying sunny weather and staying at a stunning inland location with breathtaking water views. The natural beauty of the surroundings, combined with the peaceful atmosphere and clear skies, made it a truly remarkable experience. The locals were incredibly friendly and hospitable, adding to the warm and welcoming ambiance of the place. Overall, it was a memorable trip filled with beauty, tranquility, and the genuine hospitality of the Caribbean people.\"))))), mdx(\"h2\", null, \"Responsive Tailwind Background Attachment\"), mdx(\"p\", null, \"Tailwind CSS allows you to apply background attachment classes responsively at different breakpoints. To use responsive tailwind background attachment classes, you can append the breakpoint prefix to the utility class. For example, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"md:bg-scroll\"), \" sets the background attachment to scroll starting from the medium breakpoint and above.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"bg-local md:bg-scroll\\\">\\n  This element has a background image that scrolls with the content by default, but starting from\\n  the medium breakpoint and above, it changes to be fixed.\\n</div>\\n\")), mdx(\"p\", null, \"In the above example, the background attachment of the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"<div>\"), \" element is set to local (scrolls with the content) by default (bg-local), but starting from the medium breakpoint and above, it changes to be fixed (md:bg-scroll).\"), mdx(\"h2\", null, \"Tailwind Background Attachemnt Class Table\"), mdx(\"table\", null, mdx(\"thead\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"thead\"\n  }, mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Class\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Properties\"))), mdx(\"tbody\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-fixed\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-attachment: fixed;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-local\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-attachment: local;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-scroll\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-attachment: scroll;\")))), mdx(\"h2\", null, \"Windframe Tailwind blocks\"), mdx(\"p\", null, mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://app.windframe.dev/editor?id=timelines1\"\n  }, \"Timeline\")));\n}\n;\nMDXContent.isMDXComponent = true;","tableOfContents":{"items":[{"url":"#tailwind-backgound-attachment","title":"Tailwind Backgound Attachment","items":[{"url":"#applying-tailwind-background-attachment","title":"Applying Tailwind Background Attachment"},{"url":"#preview","title":"Preview"},{"url":"#responsive-tailwind-background-attachment","title":"Responsive Tailwind Background Attachment"},{"url":"#tailwind-background-attachemnt-class-table","title":"Tailwind Background Attachemnt Class Table"},{"url":"#windframe-tailwind-blocks","title":"Windframe Tailwind blocks"}]}]},"parent":{"__typename":"File","relativePath":"classes/tailwind-background-attachment.md"},"frontmatter":{"githubUrl":null,"metaTitle":"Tailwind Background Attachment","lastUpdated":"10 May 2024","metaDescription":"The bg-{attachment} utility class in Tailwind CSS allows you to control the attachment behavior of background images applied to elements."}}},"pageContext":{"id":"39116aa5-c9f2-5d23-9a37-788f80b653b8"}},"staticQueryHashes":["2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","3309287076","3309287076","3706406642","3706406642","3706406642","4045616534","4045616534","956403285"]}