{"componentChunkName":"component---src-templates-tailwindclass-js","path":"/tailwindcss/classes/tailwind-background-size/","result":{"data":{"site":{"siteMetadata":{"title":"Resources to help developers | Contrast | Devwares","docsLocation":""}},"mdx":{"fields":{"id":"8c1f1940-2146-505f-8630-ef80bd2746fa","title":"Tailwind CSS Background Size","slug":"/classes/tailwind-background-size/"},"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\": \"3 May 2024\",\n  \"title\": \"Tailwind CSS Background Size\",\n  \"metaTitle\": \"Tailwind Css Background Size\",\n  \"metaDescription\": \"The tailwind background size utility class in Tailwind CSS allows you to control the size of background images applied to elements.\",\n  \"canonicalUrl\": \"https://windframe.dev/tailwind/classes/tailwind-background-size\"\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 Size\"), mdx(\"p\", null, \"The tailwind background size utility class in Tailwind CSS allows you to control the size of background images applied to elements. With Tailwind's background size class, you can easily adjust the dimensions of background images to achieve the desired visual effect.\"), mdx(\"h2\", null, \"Applying Tailwind Background Size\"), mdx(\"p\", null, \"To apply a specific background size to an element, you can use the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"bg-{size}\"), \" utility class, where \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"{size}\"), \" represents the desired background size. Here are some common values you can use:\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-auto\"), \": The background image is displayed at its original size.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-cover\"), \": The background image is scaled proportionally to cover the entire element, potentially cropping parts of the image.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"bg-contain\"), \": The background image is scaled proportionally to fit within the element, ensuring the entire image is visible but potentially leaving empty space.\\nHere's an example:\")), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"bg-cover\\\">\\n  This element has a background image set to cover the entire area.\\n</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\": \"w-full h-full rounded-md bg-green-100 shadow-lg\"\n  }, \"\\n     \", mdx(\"img\", {\n    parentName: \"div\",\n    \"className\": \"rounded-md relative z-10 w-full h-full bg-cover bg-center\",\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 Size\"), mdx(\"p\", null, \"Tailwind CSS allows you to apply background size classes responsively at different breakpoints. To use responsive tailwind background size classes, you can append the breakpoint prefix to the utility class. For example, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"md:bg-contain\"), \" sets the background size to contain starting from the medium breakpoint and above.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-html\"\n  }, \"<div class=\\\"bg-contain md:bg-cover\\\">\\n  This element has a background image that fits within the area, but starting from the medium\\n  breakpoint and above, it covers the entire element.\\n</div>\\n\")), mdx(\"p\", null, \"In the above example, the tailwind background size of the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"<div>\"), \" element is set to contain by default \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"(bg-contain)\"), \", but starting from the medium breakpoint and above, it changes to cover the entire element \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"(md:bg-cover)\"), \".\"), mdx(\"h2\", null, \"Tailwind Background Size 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-auto\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-size: auto;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-cover\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-size: cover;\")), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"bg-contain\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"background-size: contain;\")))), 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-size","title":"Tailwind Background Size","items":[{"url":"#applying-tailwind-background-size","title":"Applying Tailwind Background Size"},{"url":"#preview","title":"Preview"},{"url":"#responsive-tailwind-background-size","title":"Responsive Tailwind Background Size"},{"url":"#tailwind-background-size-class-table","title":"Tailwind Background Size Class Table"},{"url":"#windframe-tailwind-blocks","title":"Windframe Tailwind blocks"}]}]},"parent":{"__typename":"File","relativePath":"classes/tailwind-background-size.md"},"frontmatter":{"githubUrl":null,"metaTitle":"Tailwind Css Background Size","lastUpdated":"3 May 2024","metaDescription":"The tailwind background size utility class in Tailwind CSS allows you to control the size of background images applied to elements."}}},"pageContext":{"id":"8c1f1940-2146-505f-8630-ef80bd2746fa"}},"staticQueryHashes":["2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","2619113677","3309287076","3309287076","3706406642","3706406642","3706406642","4045616534","4045616534","956403285"]}