Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
How to make a div resize based on its background image using tailwind

So i'm using the library called Swiper for my swiper , my code looks like this :

import SwiperCore, { Pagination } from "swiper";

SwiperCore.use([Pagination]);

const MainCarousel = () => {
  return (
    <Swiper
      pagination={true}
      spaceBetween={50}
      slidesPerView={1}
      onSlideChange={() => console.log("slide change")}
      onSwiper={(swiper) => console.log(swiper)}
    >
      <SwiperSlide>
        <div className="w-screen h-screen max-h-max bg-first-car bg-cover">
          Hello
        </div>
        {/* <img src={Car1} alt=""></img>  */}
      </SwiperSlide>
      <SwiperSlide>
        {/* <img src={Car2} alt=""></img> */}
        <div className="w-screen h-screen bg-second-car bg-cover">hello</div>
      </SwiperSlide>
      <SwiperSlide>
        {/* <img src={Car3} alt=""></img> */}
        <div className="w-screen h-screen bg-third-car bg-cover">hello</div>
      </SwiperSlide>
    </Swiper>
  );
};

export default MainCarousel;

Here is what i'm trying to achieve

mine either goes to full screen if i set h-screen , but doesn't work to just fit the image and that's it , any tips ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!