How can I create a component that dynamically adjusts to different screen sizes

I have developed three child components for the main content area (excluding the header)

However, one of the components is not responsive.

Below is the code snippet:

<div className="row" style={{marginTop:'30px',}}>
        <div className="col-sm-12 col-md-12 col-lg-12">
        <div className="col-sm-3 col-md-3 col-lg-3" style={{display:'-webkit-inline-box', padding:'0px',}}>
            <label style={{backgroundColor: '#ffffff',margin: '5px 10px 5px 5px', position:'relative', float:'left',}} htmlFor="Airport_List">Airport :</label>
            <select value={this.state.airport} onChange={this.handleAirportChange} className="form-control" style={{width:'140px'}}>
            <option value="London">London</option>
            <option value="Houston">Houston</option>
            <option value="California">California</option>
            <option value="New Delhi">New Delhi</option>
            <option value="Moscow">Moscow</option>
            </select> 

        </div> 

        <div className="col-sm-3 col-md-3 col-lg-3" style={{display:'-webkit-inline-box', padding:'0px',}}>

            <span className="fa fa-plane" style={{padding:'5px',fontSize:'20px',}}></span>
            <label style={{backgroundColor: '#ffffff',margin: '5px 10px 5px 5px',}} htmlFor="Flight No">Flight :</label>
            <input style={{
            width:'150px',
            margin: '0',
            outline: '0',
            border: '1px solid #e6ecf0',
            padding:'5px',
            borderRadius: '3px',backgroundColor:'#ffffff',color: 'rgb(158, 158, 158)',}} onChange={this.handleFlightChange}  type="text" id="flightNo" name="flight_no" className="form__input" placeholder="Flight NO"  required/>

        </div>

        <div className="col-sm-3 col-md-3 col-lg-3">

            <div style={{float:'right', display:'-webkit-inline-box',margin:'5px',}}>

            <label style={{backgroundColor: '#ffffff',margin: '5px 6px 5px 5px',}} htmlFor="Date">Date :</label>
            <div className='input-group date' id='datetimepicker8' style={{left:'12px',}}>
            <DateTimePicker 
              onChange={this.onDateChange}
              value={this.state.date}
              minDate={new Date()} 
              name="datetime"

            />
            </div>
            </div> 
        </div>
        <div className="col-sm-2 col-md-2 col-lg-2">

          <Button variant="contained" color="primary" style={{width:'100px', fontSize:'12px'}} onClick={this.handleSubmit}>
               Fetch
          </Button>

         </div>

         <div className="col-sm-1 col-md-1 col-lg-1">

            <div style={{position:'relative', bottom: '10px',}}>
           <Fab color={this.state.color} onClick={()=>this.RecordAudio(this.state.color)}>
             {this.state.icon}
           </Fab>
           </div> 

         </div> 

        </div>

The Date component uses react-datetime-picker (Link)

In full-screen mode, it appears like this

https://i.sstatic.net/epfw1.png

But when I reduce the browser screen size, it looks like this :

https://i.sstatic.net/5oX6g.png

This issue has never arisen before.

Answer №1

Ensure that you are using the correct version of bootstrap and don't forget to include this meta tag in your HTML head section:

<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

Answer №2

I made improvements to your code, which now appears as shown below

<div className="row" style={{marginTop:'30px',}}>
    <div className="col-sm-6 col-md-3 col-lg-3" style={{display:'-webkit-inline-box', padding:'0px',}}>
        <label style={{backgroundColor: '#ffffff',margin: '5px 10px 5px 5px', position:'relative', float:'left',}} htmlFor="Airport_List">Airport :</label>
        <select value={this.state.airport} onChange={this.handleAirportChange} className="form-control" style={{width:'140px'}}>
          <option value="London">London</option>
          <option value="Houston">Houston</option>
          <option value="California">California</option>
          <option value="New Delhi">New Delhi</option>
          <option value="Moscow">Moscow</option>
        </select>
    </div>

    <div className="col-sm-6 col-md-3 col-lg-3" style={{display:'-webkit-inline-box', padding:'0px',}}>
      <span className="fa fa-plane" style={{padding:'5px',fontSize:'20px',}}> </span>
      <label style={{backgroundColor: '#ffffff',margin: '5px 10px 5px 5px',}} htmlFor="Flight No">Flight :</label>
      <input style={{
        width:'150px',
        margin: '0',
        outline: '0',
        border: '1px solid #e6ecf0',
        padding:'5px',
        borderRadius: '3px',backgroundColor:'#ffffff',
        color: 'rgb(158, 158, 158)',}}  
        onChange={this.handleFlightChange}  
        type="text" 
        id="flightNo" 
        name="flight_no" 
        className="form__input" 
        placeholder="Flight NO"  required/>
    </div>

    <div className="col-sm-6 col-md-3 col-lg-3">

    <div style={{float:'right', display:-webkit-inline-box',margin:'5px',}}>

        <label style={{backgroundColor: '#ffffff',margin: '5px 6px 5px 5px',}} htmlFor="Date">Date :</label>
        <div className='input-group date' id='datetimepicker8' style={{left:'12px',}}>
          <DateTimePicker
            onChange={this.onDateChange}
            value={this.state.date}
            minDate={new Date()}
            name="datetime"
          />
        </div>
      </div>
    </div>

    <div className="col-sm-4 col-md-2 col-lg-2">
      <Button variant="contained" color="primary" style={{width:'100px', fontSize:'12px'}} onClick={this.handleSubmit}>Fetch</Button>
    </div>

    <div className="col-sm-2 col-md-1 col-lg-1">
      <div style={{position:'relative', bottom: '10px',}}>
        <Fab
          color={this.state.color}
          onClick={() => this.RecordAudio(this.state.color)}
        >{this.state.icon}</Fab>
      </div>
    </div>
</div>

If you are not already using it, please include the meta tag recommended by Rishab.

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

Is there a way to connect a CSS external file that is saved on Dropbox?

Is it possible to link an external CSS file stored in Dropbox with HTML? I have followed all the instructions I could find online, including clicking and pressing "Copy Dropbox Link" to generate an href link. However, it doesn't seem to be working. ...

React Hooks: In useEffect(), unable to modify parent component's state

Within my component, I have a form for users to input a title, description, and images. This component is nested within its parent component, and I want the form data to be saved if the user switches sections and returns later without losing their progress ...

What is the best way to prevent card-group from wrapping on smaller screens?

What is the best way to ensure that cards in a card-group stay adjacent to each other on smaller screens? Currently, they are grouped together on larger screens but appear separated on smaller screens. I am currently hiding the additional cards on smaller ...

Trouble with jQuery delay in updating the CSS attribute while using fadeIn

After writing a simple JQuery code, I noticed that every time I click on 'eat', the animation lags. Is there any way to preload this animation for smoother performance? The #custom_menu element is a full-page section with a fixed position (simil ...

When transitioning to mobile size, I aim to maintain the consistent design of my background-color circle using Bootstrap 5

I am working on creating a card design with a colored background instead of an image. However, I am facing an issue where the rounded-circle background color changes to an ellipsoid shape after passing the mobile size (sm or xs). Here is what I am aiming ...

Issue encountered while designing a 3-column card grid with Bulma and Nextjs while fetching data

Trying to implement a 3 Column Card Grid using Bulma in Nextjs with data fetched from a JSON Endpoint. The data retrieval is successful and working perfectly, but struggling to identify the issue. Is there a way to limit the columns? In Bootstrap, used C ...

**The requested resource does not contain the 'Access-Control-Allow-Origin' header.**

When sending emails from a local server using nodemailer, everything works fine. But when on production, an error is thrown in the console: "No 'Access-Control-Allow-Origin' header is present on the requested resource." The setup includes a nod ...

The total accumulation of information stored in a Firebase document

Calculating the sum of Firebase data Currently, I am working on a web application and I need to create a function that will total up all the integers found in the "equipment" field across all documents within the "epis" collection. This application was d ...

Errors have popped up unexpectedly in every test file after importing the store into a particular file

Using Jest and Enzyme to test a React application has been successful, but encountering failures when importing redux store in a utility file. The majority of tests fail with the following error: FAIL app/containers/Login/LoginContainer.test.js ● Te ...

Tips for retrieving react-cookies when CORS is restricting access

Using react-cookies, I am trying to transfer data from the client side to the server side. However, when examining the request in NodeJS, I cannot locate any cookies in the headers or elsewhere. It seems that the cookies may not have been sent. After some ...

Using React Context to trigger a state change when a button is clicked

As I navigate my way through the React ecosystem as a newcomer, I find myself using a React Context to handle state management in my Next.js App. The challenge lies within my Context file: import { useState, createContext, useContext } from "react&quo ...

Learn how to successfully import a webp image into a React TypeScript project

I have looked everywhere for the answer, but I can't seem to find it When trying to import a *.webp image in typescript, you need to create a declaration file, like declaration.d.ts The declaration file should contain something similar to the foll ...

Guide to incorporating checkboxes and onChange events in React applications

I need some clarification on these codes as I am a bit confused. Can you please let me know if my understanding is correct? I have listed them out below. The state variable isChecked initially has the value of false. This means that the checkbox is cu ...

What are some ways to stop a jQuery script from running on a mobile device?

Currently in the process of developing a website with responsive design. I'm looking for ways to prevent the code below from running if a user accesses the site using a mobile device. Any suggestions on how to accomplish this? The Code: var leftHeig ...

Conceal a Column in Material UI Data Grid Filter

I've managed to conceal the id within the columns, but how can I also hide it in the filter? <StyledDataGrid getRowId={(r) => r.newId} columns={columns} rows={rows} disableSelectionOnClick checkboxSelection />; const columns = [ ...

Dynamic React animation with sliding elements

When jumping between the second and third "page" of content, I am unable to determine the reason why it is happening. The content is displayed as an absolute position. Check out the sandbox here: https://codesandbox.io/s/nostalgic-bhabha-d1dloy?file=/src ...

Exploring ways to retrieve the chosen value from a personalized dropdown menu in React?

I'm currently utilizing styled components along with typescript to retrieve the selected option value of a customized dropdown. However, I am encountering an issue where the value does not update as expected. Interestingly, when I remove the opacity f ...

It seems like the Next.js middleware.ts file is running twice, which may also be causing the app to render twice

After investigating the middleware, we discovered that it is executing functions twice, including the application itself. To troubleshoot this issue, I removed the "favicon" from a matcher in the resources where middleware is used because there were talks ...

Floating navigation bar that appears and disappears as you scroll

My webpage has a dynamic navbar that consists of two parts: navbarTop and navbarBottom. The navbarTop should appear when the user has scrolled down more than 110 pixels, while the navbarBottom should show up when the user scrolls up. The issue I am facing ...

Getting started with CSS and HTML: Tips and Tricks for Beginners

Seeking advice on how to enhance my web designing skills, particularly in starting point and techniques. Currently, I am familiar with HTML and CSS, but have been primarily using pre-made templates for building websites. I aspire to be able to transform ...