Tailwind: container breakpoint cutting off background image

Viewed 23

I want to put a contain around my page so that on very large screens the content stays in the middle of the screen.

But I have a background image i want to still show over the container. Does anyone know how I would achieve this?

export const PreviewScreen: React.FC = () => {
  return (
    <div className="sm:ml-0 xl:container xl:mx-auto">
      <div className="text-mainText font-Montserrat">
        <PreviewPageNav />
        <div className="ml-2">
          <div className="ml-36 h-14">
            <div className="bg-landing-background bg-no-repeat bg-14 bg-center-2 h-14 bg-center-2">
              <p className="text-5xl font-Montserrat">
                One workspace <br /> Every team
              </p>
            </div>
          </div>
          {/* <PackageCards /> */}
          {/* <StoreContact /> */}
        </div>
      </div>
    </div>
  );
};

enter image description here

I want the image to go to the edge of the screen and not get cut off.

1 Answers

The <div> that has the container will need a parent <div> that is full width and has the image in it.

Here is an example

<div class="grid bg-center bg-[url('https://images.unsplash.com/photo-1554629947-334ff61d85dc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2560&h=2560&q=80')] bg-cover">
  <div>
    <div class="container m-5 mx-auto bg-slate-200 p-1 h-96">Hello World</div>
  </div>
</div>

https://play.tailwindcss.com/Rgrs0CG87b

Related