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

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

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

Generate individual CSS files using postcss and rollup

When I import each css file in my JavaScript, I want it to generate a new css file for the build. For example: import "./app.css"; import "./admin.css"; This would result in creating dist/app.css and dist/admin.css. My configuration fi ...

What could be causing my 3D model to not align with what it's supposed to look like

I have been working on a website using React and Next.js, and I am trying to incorporate a 3D model into my site. After downloading a file in glb format, I noticed some discrepancies between the model I saw on this website and the one displayed on my own w ...

Website Navigation: A guide to organizing columns and rows for optimal user experience

Just reaching out with a question regarding my coding process. Currently, I am in the midst of translating the website's navigation design into code. The attached image showcases the navigation layout consisting of 10 rows and 8 columns. Below is a s ...

Utilizing Material-UI and InjectTapEventPlugin in Gatsby: A Comprehensive Guide

While incorporating the AppBar tag from material-ui into a code generated by gatsby new, I encountered this error: Warning: Unknown prop `onTouchTap` on <button> tag. Remove this prop from the element. To prevent this issue, I added the following c ...

Reactjs: useEffect fails to trigger upon initial loading

Having trouble with useEffect not triggering at app load, but only on button click. Here's my code: export default function Person() { const [person, setPerson] = useState({}); const [hitRandomUser, setHitRandomUser] = useState(0); const fetchData = ...

Modifying a property in a nested layout through a page in Next.js 13

Currently, I am facing a challenge in updating the page title within a nested layout structure. app/docs/layout.tsx: export const DocsLayout = ({children}:{children: React.ReactNode}) => { return ( <> <header> ...

Correctly align the div on the screen as the viewport is scrolled

I am currently working on a parallax website where the sliders are designed to slide from the left and align within the viewport as the user scrolls. However, I have encountered an issue where multiple scroll actions are required for the slide to align pro ...

What is the best way to draw a rectangle outline in Vue.js without the need for any additional packages?

I have been attempting to craft a rectangle outline using vueJS, but so far I have not had much success. I am hoping to achieve this using only CSS, but despite my efforts, I have not been able to find a solution. My goal is to create something similar to ...

Switch up the CSS variable within an embedded iframe

I'm in a predicament with a specific issue. I am currently utilizing Angular to incorporate an Iframe. Let's imagine the angular app as A and the Iframe as B. B is being loaded within A. Within B, I have utilized CSS variables to define colors. I ...

Tips for transforming a scroll element into the viewport using Angular 2+

This is a sample Here is a component with a list of items: class HomeComponent { text = 'foo'; testObject = {fieldFirst:'foo'}; itemList = [ '1', '2', '3', & ...

How to insert additional spacing within an input tag class in dynamic HTML using jQuery

When creating an html table dynamically from json data, I encountered an issue with adding space inside my input button control. It seems that after separating two classes with a space, the code is not functioning properly in this snippet environment. Howe ...

Utilize jQuery to toggle the visibility of a div depending on the numerical quantity input

I would greatly appreciate any assistance with this request, please. Here is the input that I have: <input onchange="UpdateItemQuantity(this.value,1284349,0,10352185,2579246,'','AU'); return false;" type="number" class="form-contro ...

Utilizing Typescript to Transfer Data from Child to Parent in React

Attempting to pass data from a Child Component to a Parent component using Typescript can be challenging. While there are numerous resources available, not all of them delve into the TypeScript aspect. One question that arises is how the ProductType event ...

"Can you provide guidance on updating the state when props are being set through the use of mapStateToProps

I implemented a text field that uses props from Redux's mapStateToProps to set its defaultValue. Whenever there is a change in the text field (detected through onChange={...}), I use setState to store user input. However, I encountered an issue wher ...

The parsing of the Next.js module failed due to an unexpected character '' appearing at the beginning of the line

It appears that there is no appropriate loader set up to handle this file type. You can refer to https://webpack.js.org/concepts#loaders for more information. I have tried various methods found online to address this issue, but none of them have worked so ...

Obtain all data through Prisma Findmany Many to Many connections

When looking at the Prisma FindMany Include example (https://www.prisma.io/docs/getting-started/quickstart), the data model is defined as follows: model User { id Int @id @default(autoincrement()) email String @unique name String? posts Po ...

Tips for creating multiple diagonal lines with CSS and HTML

Is there a way to create multiple diagonal lines within a rectangle using CSS and HTML from the start? I am interested in incorporating diagonal lines at the onset of the rectangle. Here is an example code that displays the rectangle: <div className={ ...

I encountered an issue when trying to run the npm start command. Can anyone help

I have encountered some errors in my React project and attached an image. Can someone guide me on how to resolve these issues? I am new to React and struggling with this. ...

"Exploring the features of next-auth server-side implementation in the latest version of Next.js,

Is it possible to utilize next-auth in a Next.js 14 application router to access user sessions and display page responses using SSR? If so, what steps need to be taken? ...

After declaring a useState variable in React, the code following it will not be executed

Currently, I am facing a peculiar problem with the useState hook in my React project. I have a custom hook called useAxios which relies on useState to handle state management. Strangely, any console.log commands placed after the useState declarations do no ...