Struggling to minimize the dimensions of the Image div in React Js with Tailwind CSS

I am currently working on replicating the functionality of the Book My show Application. Specifically, I am developing a Cast and Crew slider. Despite my efforts to decrease the size of the images, the spacing between them remains unchanged.

Here is my Javascript file that includes the source and settings for the slider:

import React from "react";
import Slider from "react-slick";

import CastPoster from "../MovieCast/movieCast.component";

const Cast = (props) => {
 
    const settings = {
        infinite: true,
        autoplay: false,
        speed: 1500,
        slidesToShow: 4,
        slidesToScroll: 2,
        InitialSlide: 0,
    }
    
    const CastImages = [
        {
            src:"https://in.bmscdn.com/iedb/artist/images/website/poster/large/simu-liu-2006167-13-05-2021-04-13-21.jpg",
            name:"Simu Liu",
            role:"as Shang-Chi"
        },

        {
            src:"https://in.bmscdn.com/iedb/artist/images/website/poster/large/awkwafina-1093500-20-06-2018-12-05-44.jpg",
            name:"Awkwafina",
            role:"as Katy"
        },

        {
            src:"https://in.bmscdn.com/iedb/artist/images/website/poster/large/tony-leung-iein105711-02-04-2018-13-07-58.jpg",
            name:"Tony Leung Chiu-wai",
            role:"as Wenwu / The Mandarin"
        },

        {
            src:"https://in.bmscdn.com/iedb/artist/images/website/poster/large/michelle-yeoh-1473-24-03-2017-17-32-23.jpg",
            name:"Michelle Yeoh",
            role:"as Jiang Nan"
        }
    ];
    
    return (
        <>
        <div className="">
            <Slider {...settings}>
                {
                    CastImages.map((data) => (
                        <CastPoster {...data} />
                    ))
                }
            </Slider>  
        </div>
        </>
    )
};

export default Cast;

This is the Javascript file responsible for rendering the slider:

import React from "react";

const CastPoster = (props) => {
    return (
        <>
        <div className="">
                <img className="rounded-full w-32 h-32 " src={props.src} atl={props.name} />
            <div>
                <h3>{props.name}</h3>
                <p>{props.role}</p>
            </div>
        </div>
        </>
    );
};

export default CastPoster;

Furthermore, I have integrated it as a component in a page:

import React from "react";
import Cast from "../components/Cast/Cast.component";
import MovieHero from "../components/MovieHero/MovieHero.component";
import offerIcon from "./offericon.png";


const MoviePage = () => {
    return (
        <>
        <MovieHero />
        <div className="my-12 container px-4 lg:w-3/4 lg:ml-20">
            <div className="flex flex-col items-start gap-3">
                <h2 className="text-gray-800 font-bold text-2xl"> About the movie </h2>
                <p> Shang-Chi and The Legend of The Ten Rings features Simu Liu as Shang-Chi, who must confront the past he thought he left behind when he is drawn into the web of the mysterious Ten Rings organization. The film is directed by Destin Daniel Cretton and produced by Kevin Feige and Jonathan Schwartz.</p>
            </div>
            <div className="my-8">
                <hr />
            </div>
            <div>
                <h1 className="text-gray-800 font-bold text-2xl pb-4"> Applicable Offers </h1>
                <div className="flex items-start gap-2 bg-yellow-100 border-yellow-400 border-2 border-dashed rounded-md p-3 w-96">
                    <img className="h-6" src={offerIcon}/>
                    <div className="flex flex-col items-start">
                        <h3 className="relative -top-1 text-gray-900 text-md font-semibold"> Filmy Pass </h3>
                        <p className="text-gray-600 -top-1 text-sm"> Get Rs.75* off on 3 movies you buy/rent on Stream. Buy Filmy Pass @Rs.99 </p>
                    </div>
                </div>
            </div>
            <div className="my-8">
                <hr />
            </div>
            <div>
                <h3> Cast </h3>
                <div>
                    <Cast />
                </div>
            </div>
        </div>
        </>
    )
};

export default MoviePage;

The outcome: This displays the output of the code

I am looking to minimize the space between the images. Thank you.

Answer №1

To adjust the spacing between your images, consider the number of slides you want to display and the width of the slider container. If you want less space between the images, either decrease the width of the slider or increase the number of images shown.

One way to structure your Cast component could be:

<div className="w-full">
    <Slider {...settings} className="w-1/2">
        {
            CastImages.map((data) => (
                <CastPoster {...data} />
            ))
        }
    </Slider>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When working with NodeJS, Express, and MySQL, it is important to avoid setting headers after they have already been sent

I am working on a NodeJS application using Express and here is the relevant code snippet. app.post('/open', checkStatus, function(req, res) { if (req.error) { console.log(req.log); return res.json(req.error); } console.log(current ...

Error: The term 'RequestCompleted' is not recognized by Microsoft JScript

Does anyone have any suggestions? The error above occurs when this code is executed: Sys.WebForms.PageRequestManager.getInstance().add_endRequest(RequestCompleted); Specifically within this section: <script language="javascript" type="text/javas ...

Guide to updating passwords with passport-local-mongoose

After successfully importing the passport-local-mongoose to my code and being able to register and log in users, I now face the challenge of changing the password for a specific user. How can I achieve this? According to the documentation of passport-local ...

How can CSS be used to create a responsive form script?

We have enlisted the services of an SEO provider through upcity.com, which necessitates us to embed a form on our website. However, we are facing challenges with the responsiveness of the form on mobile devices, which undermines our efforts. Therefore, I a ...

I was unable to produce the result of the input value entered at the bottom

Is there a way to view the input and output simultaneously in my project? I've seen this done using a button, but I'm looking to achieve the same without a button. How can I do this? <input type="text" id="myText"> <b ...

Choose dates with ease - React Date Picker

I'm looking to develop a date range picker with the same functionality as [https://www.daterangepicker.com/], but exclusively using Material UI and React JS. I want to avoid incorporating other libraries. While Material UI provides a date picker, I am ...

What could be the reason for Angular showing the raw HTML code instead of

I'm currently diving into Angular and encountering an issue where my HTML isn't properly displaying the values I've set. It appears to only show the raw HTML. Here's a snippet from my HTML page: <p>to-do-items works!</p> < ...

Creating a navigation menu that uses images to simulate borders instead of using traditional border styling in CSS

My goal is to create a menu with a design like this: | one | two | three | four| Through CSS and borders, it's possible to achieve a similar look by: .myContainer > ul > li{ border-right: 1px solid purple; } .myContainer > ul > li ...

Struggling to get the HTML layout just right on my MVC 5 Razor Page with Bootstrap CSS

I am currently facing difficulties aligning elements and displaying them in the same row. I am using MVC 5 razor pages along with HTML and Bootstrap.css. Despite spending several days on it, I have only made minimal progress since I started. I will provide ...

Is the presence of the node_modules folder required in the server for the Next.js production build?

I'm still fairly new to Next.js and its deployment process. Recently, I made the switch from one of my React.js projects to Next.js to take advantage of its server-side rendering feature. However, when it came time to deploy, I realized that the Next ...

What solutions do Next.js 13 and React server components offer to address the problem of network latency?

Imagine a scenario where I have a primarily static, content-oriented website developed in Next.js. Currently, I am statically generating or server-side rendering all pages, then implementing a CDN and configuring headers to cache my static assets on the C ...

Declare a state in React based on certain conditions

Is it possible to conditionally set up a state based on a certain prop being provided? Consider the following scenario: function Component({scroll, children}) { const [scrollY, setScrollY] = useState(0); useEffect(() => { if (scroll) { ...

Proxy/firewall causing interference with socket connection from chrome extension

I have encountered an issue with my web app in JavaScript that connects to a socket using socket.io and a Chrome Extension that also connects in the same way to the same server. While everything works smoothly on most computers and internet connections, th ...

Updating the state of a disabled field in a React component

I have been trying to display a default value and disable the field. The values are successfully displayed but the state is not getting updated. Can someone please guide me on how to update the state of a disabled field? I have put in a lot of effort but h ...

Reordering a pair of items within an array using ReactJS

After pondering, I wondered if there exists a neat and tidy method to swap two objects within an array while utilizing setState. Here's my current approach: export function moveStepUp(index) { if(index > 0){ let currentStep = this.stat ...

Guidelines on incorporating HTML files as templates into Rollup and compiling them into concatenated strings

I am currently working on setting up a build process for Optimizely experiments using Rollup instead of Webpack. The reason for this change is that the code exported by Webpack is too bloated for our specific use case. My goal is to import .html files as t ...

`No cookies stored on mobile devices`

I've implemented a middleware for handling protected routes using cookies for server-side checking. Upon user login, the information is saved in local storage for frontend authentication checks, and a cookie is set to true for server-side verification ...

Tips for Implementing Input Validation in Your Code

I have been attempting to design a multi-form and have been struggling to add input validation. Specifically, I want to prevent the form from progressing to the next step if certain fields (such as name) are left empty. However, despite multiple attempts, ...

When using expressjs and typescript, you may encounter an error stating that the type 'typeof <express.Router>' cannot be assigned to the parameter type 'RequestHandlerParams'

Working on my project using expressjs with the latest typescript definition file and typescript 2.3.4 from https://github.com/DefinitelyTyped/DefinitelyTyped. I've set up a router and want to access it from a subpath as per the official 4.x documentat ...

Adding information into multiple tables from a single table

I am looking to streamline the process of displaying tables with identical entries on multiple HTML pages. Is there a way to create the table in one place and then call it into other pages? Could it be done like this: <table id="table1"> <th ...