{"componentChunkName":"component---src-templates-tailwindclass-js","path":"/tailwindcss/classes/tailwind-background-position/","result":{"data":{"site":{"siteMetadata":{"title":"Resources to help developers | Contrast | Devwares","docsLocation":""}},"mdx":{"fields":{"id":"f2e170d0-c67b-5dfa-b5b2-212a8d361b2e","title":"Tailwind CSS Background Position","slug":"/classes/tailwind-background-position/"},"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\": \"4 May 2024\",\n  \"title\": \"Tailwind CSS Background Position\",\n  \"metaTitle\": \"Tailwind Background Position\",\n  \"metaDescription\": \"The bg-{position} utility class in Tailwind CSS allows you to control the positioning of background images applied to elements. With Tailwind background position class, you can easily adjust the placement of background images to achieve the desired visual effect\",\n  \"canonicalUrl\": \"https://windframe.dev/tailwind/classes/tailwind-background-position\"\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 Background Position\"), mdx(\"p\", null, \"The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"bg-{position}\"), \" utility class in Tailwind CSS allows you to control the positioning of background images applied to elements. With Tailwind background position class, you can easily adjust the placement of background images to achieve the desired visual effect.\"), mdx(\"h2\", null, \"Applying Tailwind Background Position\"), mdx(\"p\", null, \"To apply a specific tailwind background position to an element, you can use the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"bg-{position}\"), \" utility class, where \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"{position}\"), \" represents the desired background position. Here are some common values you can use:\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-top\"), \": The background image is positioned at the top of the element.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-center\"), \": The background image is positioned at the center of the element.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-bottom\"), \": The background image is positioned at the bottom of the element.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-left\"), \": The background image is positioned at the left side of the element.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-right\"), \": The background image is positioned at the right side of the element.\\nHere's an example:\")), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"bg-top-left\\\"></div>\\n<div class=\\\"bg-top\\\"></div>\\n<div class=\\\"bg-top-right\\\"></div>\\n\")), mdx(\"h2\", null, \"Preview\"), mdx(\"div\", {\n    \"className\": \"rounded-t-xl overflow-hidden bg-green-200 p-10\"\n  }, \" \\n\", mdx(\"div\", {\n    parentName: \"div\",\n    \"className\": \"grid grid-cols-3 gap-4\"\n  }, \"\\n  \", mdx(\"div\", {\n    parentName: \"div\",\n    \"className\": \"w-32 h-32 rounded-md bg-green-100 shadow-lg\"\n  }, \"\\n  \", mdx(\"img\", {\n    parentName: \"div\",\n    \"className\": \"w-16 h-16 rounded-md overflow-hidden bg-left-top\",\n    \"src\": \"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  }), \"\\n  \"), \"\\n  \", mdx(\"div\", {\n    parentName: \"div\",\n    \"className\": \"w-32 h-32 rounded-md bg-green-100 shadow-lg\"\n  }, \"\\n     \", mdx(\"img\", {\n    parentName: \"div\",\n    \"className\": \"mx-auto w-16 h-16 rounded-md overflow-hidden bg-top\",\n    \"src\": \"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  }), \"\\n  \"), \"\\n   \", mdx(\"div\", {\n    parentName: \"div\",\n    \"className\": \"w-32 h-32 rounded-md bg-green-100 shadow-lg\"\n  }, \"\\n     \", mdx(\"img\", {\n    parentName: \"div\",\n    \"className\": \"ml-16 w-16 h-16 rounded-md overflow-hidden bg-right-top\",\n    \"src\": \"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  }), \"\\n  \"))), mdx(\"h2\", null, \"Responsive Tailwind Background Position\"), mdx(\"p\", null, \"Tailwind CSS allows you to apply background position classes responsively at different breakpoints. To use responsive tailwind background position classes, you can append the breakpoint prefix to the utility class. For example, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"md:bg-right\"), \" sets the background position to the right starting from the medium breakpoint and above.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"bg-left md:bg-right\\\">\\n  This element has a background image that is positioned at the left by default, but starting from\\n  the medium breakpoint and above, it changes to the right side.\\n</div>\\n\")), mdx(\"p\", null, \"In the above example, the tailwind background position of the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"<div>\"), \" element is set to the left by default \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"(bg-left)\"), \", but starting from the medium breakpoint and above, it changes to the right side \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"(md:bg-right)\"), \".\"), mdx(\"h2\", null, \"Tailwind Background Position 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-bottom\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: bottom;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-center\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: center;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-left\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: left;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-left-bottom\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: left bottom;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-left-top\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: left top;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-right\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: right;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-right-bottom\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: right bottom;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-right-top\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: right top;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-top\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-position: top;\")))), 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-background-position","title":"Tailwind Background Position","items":[{"url":"#applying-tailwind-background-position","title":"Applying Tailwind Background Position"},{"url":"#preview","title":"Preview"},{"url":"#responsive-tailwind-background-position","title":"Responsive Tailwind Background Position"},{"url":"#tailwind-background-position-class-table","title":"Tailwind Background Position Class Table"},{"url":"#windframe-tailwind-blocks","title":"Windframe Tailwind blocks"}]}]},"parent":{"__typename":"File","relativePath":"classes/tailwind-background-position.md"},"frontmatter":{"githubUrl":null,"metaTitle":"Tailwind Background Position","lastUpdated":"4 May 2024","metaDescription":"The bg-{position} utility class in Tailwind CSS allows you to control the positioning of background images applied to elements. With Tailwind background position class, you can easily adjust the placement of background images to achieve the desired visual effect"}}},"pageContext":{"id":"f2e170d0-c67b-5dfa-b5b2-212a8d361b2e"}},"staticQueryHashes":["2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","3309287076","3309287076","3706406642","3706406642","3706406642","4045616534","4045616534","956403285"]}